我是 php 和编程的新手,我一直在学习教程,但是在尝试将产品显示到网页上时遇到了问题,这是正在测试的代码
<?php
if (isset($_GET['id'])) {
include "storescripts/connect_to_mysql.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
$sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
$productCount = mysql_num_rows($sql);
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
} else {
echo "That item does not exist.";
exit();
}
} else {
echo "Data to render this page is missing.";
exit();
}
mysql_close();
?>
当我尝试通过浏览器查看页面时,我收到消息“缺少呈现此页面的数据”
我知道这与
if (isset($_GET['id'])) {
我假设这可能与“id”有关,但我不知道如何解决它。任何指示和帮助将不胜感激,如果这看起来很基本,但就像我说的那样,我是新手,无法解决这个问题。我整天都在努力
谢谢