2016-03-13 21 views
1

有沒有什麼辦法可以在php中打開一個按鈕來打開新標籤中的鏈接? 我有鏈接 解決了開Iframe的問題,但現在我想在頁面頂部的按鈕返回到主頁 我該怎麼辦添加如何製作一個按鈕在php上打開一個新標籤中的鏈接

<?php 
 
$host="localhost"; // Host name 
 
$username="publiadd_publix"; // Mysql username 
 
$password="1a3g7893fsh"; // Mysql password 
 
$db_name="publiadd_urlrotator"; // Database name 
 
$tbl_name="url_rotator"; // Table name 
 

 
// Connect to server and select database. 
 
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
 
mysql_select_db("$db_name")or die("cannot select DB"); 
 

 
    $query = 'SELECT * FROM url_rotator ORDER BY root_name DESC LIMIT 10'; 
 
    $result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.<br />Query: ".$query."<br />Error: (".mysql_errno().") ".mysql_error()); 
 
// Print Title 
 

 
print '<center>'."All Rotator In Our Network! ".'</center>'; 
 
print '<center>'."---------------------------".'</center>'; 
 
    while ($row = mysql_fetch_assoc($result)) { 
 
      $id = $row['id']; 
 
      $root_name = $row['root_name']; 
 
      $root_url1 = $row['root_url1']; 
 
      $root_url2 = $row['root_url2']; 
 
      $root_url3 = $row['root_url3']; 
 
      $root_url4 = $row['root_url4']; 
 
      $root_url5 = $row['root_url5']; 
 
      $root_url6 = $row['root_url6']; 
 
      $root_url7 = $row['root_url7']; 
 
      $root_url8 = $row['root_url8']; 
 
      $root_url9 = $row['root_url9']; 
 
      $root_url10 = $row['root_url10']; 
 
echo '<center>'.$row['id'] . " | " . $row['root_name'] . " | " .'</center>' ; 
 
echo '<center>'.$row['root_url1'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url2'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url3'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url4'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url5'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url6'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url7'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url8'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url9'] . " * " .'</center>' ; 
 
echo '<center>'.$row['root_url10'] . " * " .'</center>' ; 
 
echo "<iframe src=\"{$root_url1}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url2}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url3}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url4}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url5}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url6}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url7}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url8}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url9}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
echo "<iframe src=\"{$root_url10}\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>"; 
 
    }//end while 
 
// close MySQL connection 
 
mysql_close(); 
 
?> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
 
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'"> 
 
<link rel="stylesheet" href="style.css" type="text/css" /> 
 
//<a href="<?php echo $root_url10 ?>"><?php echo $root_url10 ?></a> 
 
</head> 
 
<body bgcolor="#ffffff"> 
 
<center><br><br><form> 
 
<input type="button" value="Back" onclick="window.location.href='http://bitcoinrotator.publiadds.org.pt/login-registration/home.php'" /> 
 
</form></center> 
 
</body>

+3

是不是有可能像樣式的按鈕鏈接和公正使用target =「_空白」? – SuperDJ

+0

坦克你有重播 –

+0

我想要放置這個按鈕是我的打印指示 –

回答

1

只需將window.location.href替換爲window.open即可。

試試這個:

<?php 
    $host="localhost"; // Host name 
    /* Codes */ 
     $result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.<br />Query: ".$query."<br />Error: (".mysql_errno().") ".mysql_error()); 
    // Print Title 
?> 
<!-- Place your button below, separated from PHP tag --> 
<input type="button" value="Back" onclick="window.open('http://bitcoinrotator.publiadds.org.pt/login-registration/home.php')" /> 
<center>'."All Rotator In Our Network! ".'</center> 
<center>'."---------------------------".'</center> 

<?php 
/* While loop and other codes */ 
?> 
+0

坦克你的幫助,我有嘗試,但沒有加載頁面 –

+0

你的意思是它不開放在新標籤中?你可能想重試,因爲我剛剛檢查出它似乎工作得很好。 :) –

+0

問題是我想要在頁面頂部和頁面頂部的這個按鈕我有PHP代碼,所以如何把這個HTML按鈕中間的PHP代碼?我喜歡將它放在//打印標題 –

相關問題