I have a search bar and a sql database with 3 movies in
Name:Star Wars: Description: Contains the word group
Name:301: Description: Contains the word group
Name:destroyer: Description: Contains the word group
BUT when ever I search for the word "group"
I only get one result usually:
here is my php code:
if(!isset($_POST['search']))
{
header("Location:index.php");
}
$search_sql="SELECT * FROM php_item WHERE Name LIKE '%".$_POST['search']."%' OR Description LIKE '%".$_POST['search']."%'";
$search_query = mysql_query($search_sql);
if(mysql_num_rows($search_query)!=0)
{
$search_rs= mysql_fetch_assoc($search_query);
}
?>
</p>
<p> Search Results</p>
<?php
if(mysql_num_rows($search_query) != 0){
do{ ?>
<p>
<?php echo $search_rs['Name']; ?>
<?php }while($searchr_rs=mysql_fetch_assoc($search_query));
} else {
echo "No Results Found";
}
?>
EDIT changed $search_rs to $searchr_rs in my old post & now it will work
<?php
if(!isset($_POST['search']))
{
header("Location:index.php");
}
$search_sql="SELECT * FROM php_item WHERE Name LIKE '%".$_POST["search"]."%' OR Description LIKE '%".$_POST["search"]."%' ";
$search_query = mysql_query($search_sql);
//print_r($search_query);
if(!$search_query){
die(mysql_error());
}
if(mysql_num_rows($search_query)>0)
{
echo '<p> Search Results</p>';
while($searchr_rs=mysql_fetch_array($search_query))
{
echo ' <p>';
echo $searchr_rs['Name'];
echo '</p>';
}
} else {
echo "No Results Found";
}
?>