(我不再得到一个解析错误,只是一个空白APGE与我的头和NAV酒吧,所以请看到它是不是重复后)SQL/PHP - 空白结果页面链接
我有下面的代码将添加一个链接到详细信息页面。我只是不确定我需要添加到详细信息页面来回显“名称”,我坚持并非常感谢我能得到的任何帮助。目前,当我点击搜索结果中的链接时,我只是处于空白时代。
的search.php
<?php
$page='search';
include('header.php');
include ('navbar.php');
echo "<br>";
include ('connect.php');
if (isset ($_POST['search'])) { //the 'search' refers to the 'search' name=search on the index page and makes does something when the search is pushed.
$search = $_POST['search'];
$search = "%" . $search . "%"; // MySQL wildcard % either side of search to get partially matching results
// No wildcard if you want results to match fully
} else {
header ('location: index.php');
}
$stmt = $conn->prepare("SELECT * FROM test_db WHERE name LIKE :name ORDER BY name ASC"); // Use = instead of LIKE for full matching
$stmt->bindParam(':name', $search);
$stmt->execute();
$count = $stmt->rowCount(); // Added to count no. of results returned
if ($count >= 1) { // Only displays results if $count is 1 or more
echo "<div class='results_found'>";
echo $count;
echo " results found<br>";
echo "</div>";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<div class='results'>";
echo "<div class='result_name'>";
echo "<b>Whisky Name:</b><br>";
echo "<a href='details.php?id={$row['lot_id']}' >{$row['name']}</a>;";
echo "</div>";
echo "</div>";
}
} else {
echo " Sorry no records were found";
}
?>
Details.php
<?php
$page='details';
include('header.php');
include ('navbar.php');
include ('connect.php');
if (isset($_GET['lot_id'])) {
echo $row['name'];
?>
</html>
什么是行(在$ _GET ['lot_id' ]);意味着做什么?如果不是这样。如果(isset($ _GET ['lot_id']){echo $ row ['name'])} –
你的问题到底是什么? – Ibu
我的问题是如何在点击我创建的链接后回显所需的重复我的搜索结果页面,进行搜索并显示结果,然后我希望能够点击任何结果,并进入一个页面,这将给我更多detials。现在我只是得到一个空白 – Jason