如何在 php 上制作按钮,在新选项卡中打开链接


How To Make A Button On php that open a link in a new tab

有没有办法在 php 中制作一个按钮来打开新选项卡中的链接?我已经通过使用链接打开iframe来解决问题但是现在我想在页面顶部添加一个按钮以返回主页我该怎么做

<?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>

只需将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 */
?>