我对我的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 =”搜索”,我删除了意外......现在一切完美:)
mysql_query($ search_query);开始使用mysqli_query,不推荐使用mysql。 –
您是否尝试直接在数据库中执行相同的查询(例如,使用phpMyAdmin或控制台)?你以这种方式得到正确的结果吗? – Radzikowski
dint得到你的代码我的朋友请妥善处理。如果可能使它生活在一些小提琴如果可用,并停止使用mysql_ *函数它是在PHP 5.5中去除 –