2017-01-19 168 views
0

(我不再得到一個解析錯誤,只是一個空白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> 
+0

什麼是行(在$ _GET ['lot_id' ]);意味着做什麼?如果不是這樣。如果(isset($ _GET ['lot_id']){echo $ row ['name'])} –

+0

你的問題到底是什麼? – Ibu

+0

我的問題是如何在點擊我創建的鏈接後回顯所需的重複我的搜索結果頁面,進行搜索並顯示結果,然後我希望能夠點擊任何結果,並進入一個頁面,這將給我更多detials。現在我只是得到一個空白 – Jason

回答

0

請務必檢查GET變量設置:就這麼簡單

if (isset($_GET['lot_id'])) { 
    // DO something... 
} 

http://php.net/manual/en/function.isset.php

+0

所以,這將進入results.php我已經嘗試了下面,只是得到一個空白頁,當我點擊名稱,並得到發送到details.php .if(isset($ _ GET ['lot_id'])){ \t \t echo $ row ['name']; } – Jason