doujiao4705 2014-02-17 12:56
浏览 16

搜索结果未显示

I have a problem with my search.php file to render me results... I dont get any strings of error, but when I type an existing keyword I get no results... The format of the results are the same as viewed in my main content on the website (grid view)...

The code:

<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>

Any idea?

EDIT: I solved my problem, its a small mistake I made, In the HTML form of the search I forgot to give the submit button: "name="search", I removed it accidently... now everything works perfectly :)

  • 写回答

2条回答 默认 最新

  • dot_0620 2014-02-17 13:04
    关注

    You have a typo in code change code as below

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

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)