我在 PHP 中使用搜索页面。但这是一个错误。请告诉我我的错误。
错误是:
注意:未定义变量:第 22 行 I:\xampp\htdocs\tsooj\includes\search_page.php 中的 post_title
注意:未定义变量:第 26 行 I:\xampp\htdocs\tsooj\includes\search_page.php 中的 post_content
源代码在这里:
<div id="content-main">
<?php
include("includes/connect.php");
if(isset($_GET['search'])){
$search_id = $_GET['value'];
$search_query = "select * from posts where post_keywords like '%$search_id%'";
$run_query = mysql_query($search_query);
while ($search_row = mysql_fetch_array($run_query)){
$post_title = $search_row['post_title'];
$post_image = $search_row['post_image'];
$post_content = substr($search_row['post_content'],0,150);
}
?>
<h1>Your Search Result is here:<h1>
<h2><?php echo $post_title; ?></h2>
<img src="images/<?php echo $post_image; ?>">;
<p><?php echo $post_content; ?></p>
<?php } ?>
</div>