2014-02-17 235 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表单提交按钮:“名称=”搜索“,我意外删除它......现在一切正常:)