如何为一个链接到一个PHP但不同的输出的cookie

时间:2017-07-29 16:19:13

标签: javascript php mysql cookies localhost

我正在使用mysql数据库。我想创建一个链接到php页面的链接。

 <?php   
$connection = mysql_connect("localhost","root","");
mysql_select_db("scratchdisk",$connection);
$sql = "SELECT * FROM note";   
$result = mysql_query($sql);
echo "<table>";   
echo "<tr><td>#</td><td>Title</td><td>Action</td></tr>";  

while($row=mysql_fetch_assoc($result)){  
 echo "<tr><td>".$row['#']."</td><td>".$row['Title']."</td><td><a href='view.php' id='view'>View</a></td></tr>";   } 
echo "</table>"; 
?>

我希望在我的$row['#']上显示下一页,但是相同的view.php文件。

1 个答案:

答案 0 :(得分:0)

您可以使用此代码:

<?php   
$connection = mysql_connect("localhost","root","");
mysql_select_db("scratchdisk",$connection);
$sql = "SELECT * FROM note";   
$result = mysql_query($sql);
echo "<table>";   
echo "<tr><td>#</td><td>Title</td><td>Action</td></tr>";  

while($row=mysql_fetch_assoc($result)){  
 echo "<tr><td>".$row['#']."</td><td>".$row['Title']."</td><td><a href='view.php?id=" . $row['#'] . "' id='view'>View</a></td></tr>";   } 
 echo "</table>"; 
?>

view.php

if(isset($_GET['id']) && !empty($_GET['id'])){
  //Write logic here
  $id = $_GET['id'];
}