(I am no longer getting a parse error , just a blank apge with my header and nav bar- So please see that it is not a duplicate post)
I have the below code which will add a link to a details page. I am just not sure what I need to add to the details page to echo the "name" , I am stuck and really appreciate any assistance I can get. At the moment I just get a blank age when I click on the link from teh search results.
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>