基本上我创建了两个php文件。一个选择我的整个表格,并显示日期和ID号码。每个日期都有一个指向display.php文件的链接。它将ID号码拉到下一个display.php页面。我想要在display.php文件上做的是使用该PHP显示整个行。SQL WHERE ID carryover
所以我知道Select * from tablename WHERE id=1
会拉出那个数据,但是如何得到这个ID号到WHERE
的声明呢?
这是主要的页面代码:
// SQL查询 $ STRSQL = “SELECT * FROM表1”;
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {
// DATE
$strName = $row['date'];
// Create a link to display.php with the id-value in the URL
$strLink = "<a href = 'display.php?ID = " . $row['ID'] . "'>" . $strName . "</a>";
// List link
echo "<li>" . $strLink . "</li>";
}
该代码链接的作品,并去display.php。 我将如何使用与其一起拉的ID号创建链接。我会使用post命令吗?
$id= Post['id']
then WHERE id = '$id'
?
TBH我确实尝试过,没有任何东西。有什么建议么?
使用GET现在...仍然不是运气 我试过了GET语句。在我的地址栏中显示身份证号码。所以我看到了身份证号码。我试着回复ID,看看是不是我的代码搞乱了。
<?php
$dbhost = 'localhost';
$dbuser = 'myusername';
$dbpass = 'mypw';
$dbname = 'mydbname';
$id = $_GET['id'];
mysql_connect($dbhost, $dbuser, $dbpass) or die('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbname) or die('Cannot select database. ' . mysql_error());
?>
<body>
ID #<?php echo $id ?>
</body>
</html>
<body>
ID #<?php echo $id ?>
</body>
</html>
仍然没有运气
感谢GOT IT WORK ...认为我有一个额外的报价或什么。无论如何完美现在完美谢谢你! – ldiggins 2012-08-14 18:59:28