2017-01-19 13 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' ]);意味するものは?そうでないべきか? –

+0

検索結果が表示されます。検索結果が表示され、結果のいずれかをクリックして、より詳細な情報を得るページに移動したいと考えています。ページ番号をクリックすると、質問のコードが表示されます – Ibu

+0

私の質問は、私が作成したリンクをクリックした後に、必要なreusltsをどのようにエコーするのですか?(エコー$行['lot_id'])エコー$行['名前'];} – Jason

答えて

0

GET変数が設定されているかどうかをチェックするようにしてください:

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

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

+0

これはresults.phpに入っています。以下を試してみましたが、名前をクリックして取得すると空白のページが表示されます($ _ GET ['lot_id'])){ \t \t echo $ row ['name']; }詳細に送信されました。 – Jason

関連する問題