2014-02-17 117 views
1

我對我的search.php文件有問題以呈現結果... 我沒有收到任何錯誤字符串,但是當我鍵入現有關鍵字時,我得不到結果... 格式結果是在我的網站(網格視圖)的主要內容看一樣的...搜索結果不顯示

代碼:

<body> 
<?php include_once("analyticstracking.php") ?> 

<div class='container'> <!--Start of the container--> 

<div><?php include("includes/header.php"); ?></div> 
<div><?php include("includes/navbar.php"); ?></div> 
<div><?php include("includes/left_col.php"); ?></div> 
<div class='main_col'> 
<div class='main_content'> 
<?php 
include("includes/connect.php"); 

if(isset($_GET['search'])){ 

$search_id = $_GET['q']; 

$search_query = "SELECT * FROM games WHERE game_keywords LIKE '%$search_id%'"; 

$run_query = mysql_query($search_query); 

echo '<table>'; 
$games = 0; 
while($search_row = mysql_fetch_array($run_query)){ 
// make a new row after 9 games 
if($games%9 == 0) { 
if($games > 0) { 
// and close the previous row only if it's not the first 
echo '</tr>'; 
} 
echo '<tr>'; 
} 
// make a new column after 3 games 
if($games%3 == 0) { 
if($games > 0) { 
// and only close it if it's not the first game 
echo '</td>'; 
} 
echo '<td>'; 
} 

$game_id = $search_row['game_id']; 
$game_name = $search_row['game_name']; 
$game_category = $search_row['game_name']; 
$game_keywords = $search_row['game_name']; 
$game_image = $search_row['game_image']; 
?> 
<div class="game_grid"> 
<a href="game_page.php?id=<?php echo $game_id; ?>"><img src="images/games_images/<?php echo $game_image; ?>" width="120" height="120" /> 
<span><?php echo $game_name; ?></span> 
</div> 
<?php 
$games++; 
} 

} 
?> 
</table> 

</div> 
</div> 
<div><?php include("includes/footer.php"); ?></div> 

</div> <!--End of the container--> 

</body> 

任何想法?

編輯: 我解決我的問題,它的一個小錯誤,我做, 在搜索的HTML表單我忘了給提交按鈕:「NAME =」搜索」,我刪除了意外......現在一切完美:)

+0

mysql_query($ search_query);開始使用mysqli_query,不推薦使用mysql。 –

+0

您是否嘗試直接在數據庫中執行相同的查詢(例如,使用phpMyAdmin或控制檯)?你以這種方式得到正確的結果嗎? – Radzikowski

+0

dint得到你的代碼我的朋友請妥善處理。如果可能使它生活在一些小提琴如果可用,並停止使用mysql_ *函數它是在PHP 5.5中去除 –

回答

0

你在代碼 改變代碼一個錯字如下

if(isset($_GET['search'])){  
    $search_id = $_GET['search']; //$_GET['q']; 
. 
. 
.  
} 
+1

它不是那樣,它是在我把它變成「q」之前的價值,我沒有忘記將HTML搜索表單從「value」更改爲「q」以及... – davidgpilot

0

我解決我的問題,它的一個小錯誤,我提出,在我忘了給搜索的HTML表單提交按鈕:「名稱=」搜索「,我意外刪除它......現在一切正常:)