PHP/SQL显示链接结果
我已经创建了一个链接PHP/SQL显示链接结果,php,html,Php,Html,我已经创建了一个链接 echo '<a href="description.php?id='.$dash.'" >'."<strong>$name</strong>".'</a>'; 这是可行的,但会将我带到一个空白页description.php 这是我尝试的代码,没有显示任何内容 if (isset($_GET['$name'])) { $result = $_GET['$name']; $sql = "SELECT PedalID,
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();
}
有人能解释一下为什么这段代码没有显示结果吗?看起来您的链接正在发送$\u GET['id'],但您正在引用$\u 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();
}
?>
与css有什么关系?您使用的是$_-GET['name']而不是$_-GET['id'],而且在查询库中也没有使用它。我现在明白了