帮助 我有一个可点击链接的搜索,它会将您发送到另一个页面以查看完整结果,但似乎无法将ID转入/searchclick.php?id =
搜索代码
// Build SQL Query
$query = "SELECT Bird_ID, Species from Birds where Species like \"%$trimmed%\" order by Species";
$numresults=mysqli_query($conn, $query);
$numrows=mysqli_num_rows($numresults);
if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: " . $trimmed . " returned zero results</p>";
}
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysqli_query($conn, $query) or die("Couldn't execute query");
echo "<br />";
// display what the person searched for
echo "<br />";
echo "<p>You searched for: "" . $var . ""</p>";
// begin to show results set
echo "<br />";
echo "<br />";
echo "Results";
echo "<br />";
$count = 1 + $s ;
// now you can display the results returned
echo "<center>";
echo '<table cellpadding="1" cellspacing="1" border="1">';
echo '<tr><th>Bird_ID</th><th>Species</th><th>Comments</th></tr>';
while ($row= mysqli_fetch_array($result)) {
echo "<tr>";
echo '<td><a href="searchclick.php?id=">'.$row['Bird_ID'].'</a></td>';
echo '<td>'.$row['Species'].'</a></td>';
echo '<td>'.$row['Comments'].'</a></td>';
$count++ ;
}
点击结果的代码
session_start();
include '/home/wc002/include/dbconnect.php';
// get value of id that sent from address bar
$id = $_GET['id'];
// Retrieve data from database
$query = "SELECT Bird_ID, Species, Comments, Image FROM Birds WHERE Bird_ID = '$id'";
echo "<br />";
echo '<table cellpadding="1" cellspacing="1" border="1" width="100">';
echo '<tr><th>Bird ID</th><th> Species </th></tr>';
$result = mysqli_query($conn, $query) or die(mysqli_error());
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['Bird_ID'] . "</td>";
echo "<td>" . $row['Species'] . "</td>";
echo "<td>" . $row['Comments'] . "</td>";
echo "<td>" . $row['Image'] . "</td>";
echo "</td>";
}
?>
谢谢你的进步
答案 0 :(得分:1)
echo '<td><a href="searchclick.php?id=">'.$row['Bird_ID'].'</a></td>';
您实际上并未将ID放入链接中。试试这个:
echo '<td><a href="searchclick.php?id='.$row['Bird_ID'].'>'.$row['Bird_ID'].'</a></td>';