php search help
Posted: Thu Jan 22, 2015 12:59 pm
hello,
can anyone help me with my search page please.
ive got it showing the search results all I need to do now if none is return display a message saying no posts here is my code.
can anyone help me with my search page please.
ive got it showing the search results all I need to do now if none is return display a message saying no posts here is my code.
Code: Select all
<?php require("./styles/top.php");?>
<h1>Here is your search result</h1>
<?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_id = $search_row['post_id'];
$post_title = $search_row['post_title'];
$post_image = $search_row['post_image'];
$post_date = $search_row['post_date'];
$post_author = $search_row['post_author'];
$post_content = substr($search_row['post_content'],0,150);
?>
<div id="container">
<div id="image"><?php if($post_image != ""){ ?><img src="/cms/pics/<?php echo $post_image; ?>" /> <?php } ?></div>
<div id="title"><?php echo $post_title; ?></div>
<div id="posted_by">Published on: <?php echo $post_date ?> By <?php echo $post_author ?></div>
<hr style="width: 75%;" />
<div id="content"><?php echo $post_content; ?></div>
</div>
<?php } } ?>
<?php require("./styles/bottom.php");?>