我创建了一个链接
echo '<a href="description.php?id='.$dash.'" >'."<strong>$name</strong>".'</a>';
有效,但带我到一个空白页面(description.php)
这是我试过的代码,没有任何显示。
if (isset($_GET['$name'])) {
$result = $_GET['$name'];
$sql = "SELECT PedalID, Manufacturer, ProductName FROM PedalDirectory";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["PedalID"]. " - Name: " . $row["ProductName"]. " " . $row["Manufacturer"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
}
有人可以提供一些有关此代码未显示结果的信息吗?
答案 0 :(得分:0)
您的链接似乎正在发送$_GET['id']
,但您引用的是$_GET['$name']
您的代码应为
<?php
if (isset($_GET['id'])) {
$result = $_GET['id'];
$sql = "SELECT PedalID, Manufacturer, ProductName FROM PedalDirectory";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["PedalID"]. " - Name: " . $row["ProductName"]. " " . $row["Manufacturer"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
}
?>