Hello, I'm making a search function that shows results from a mySQL database, problem is that it show's results most of the time, but it also sometimes skips some results and doesn't show them.
For example, when I search for 'i' it does show the result 'In Utero' but if I search for Utero it shows a blank page, even though I scripted it so that when no results are found this is said so on screen.
Here's my code:
<?php
error_reporting(E_ALL);
include( 'phpheader.php');
include( 'header.php' );
$string= $_POST['description'];
?>
<div id="text">
<h1>Result</h1>
<div id="content">
<?php
$sql = "SELECT * FROM product JOIN producer ON product.producer_id = producer.producer_id WHERE product_name LIKE '%$string%' OR producer_name LIKE '%$string%'" ;
$query = mysql_query($sql) or die(mysql_error());
$row_sql = mysql_fetch_array($query);
$total = mysql_num_rows($query);
if($total>0) {
while ($row_sql = mysql_fetch_array($query)) {
echo ''.$row_sql['product_name].'<br />'.$row_sql['producer_name'].'<br />'.'';
}
}
else
{
echo "No results to display";
}
?>
</div>
</div>
<?php
include( 'frontend_menu.php' );
include( 'footer.php' );
include( 'phpfooter.php');
?>
Please help me, I have no idea what is wrong with it.