dangergeek
04-11-2007, 04:38 AM
Hello
Been banging my head against screen all day.
I have created a small search engine for my site but it doesnt seem to display properly.
http://www.hobao-racing.com/accessories2.php
The above link shows everything that it currently in the database. If, for example, I search for 'starter box' it only shows 1 result instead of 2, and there are clearly 2 starter boxes at the bottom of the list.
It seems to do this for a few items I search for but I can't figure out why.
this is the code I have used:
$search = $_POST["search"];
$category = $_POST["category"];
if (!empty ($search)){
$result = mysql_query("SELECT * FROM accessories WHERE code LIKE '%$search%' OR name LIKE '%$search%' OR description LIKE '%$search%'")
or die(mysql_error());
$row = mysql_fetch_array($result);
$total = mysql_num_rows($result);
if($total!='0') {
while($row = mysql_fetch_array($result)){
$display_accessories.= "<div><hr width='95%' /><br />" . "<img style='margin:0px 15px;' src='products/accessories/" . $row['category'] . "/" .$row['code'] . "/thumb.jpg' alt='". $row['name'] ."' align='left' /><b>" . $row['code'] . " - ". $row['name'] . "</b><br /><br />" . $row['description'];
$display_accessories.= "<br /><br /><br /><br /><br /><br /><br /><br /></div>";
}
} else
{
$display_accessories.= "No results to display";
}
}
else{
$result = mysql_query("SELECT * FROM accessories ORDER BY code")
or die(mysql_error());
$row = mysql_fetch_array($result);
}
while($row = mysql_fetch_array($result)){
$display_accessories.= "<div><hr width='95%' /><br />" . "<img style='margin:0px 15px;' src='products/accessories/" . $row['category'] . "/" .$row['code'] . "/thumb.jpg' alt='". $row['name'] ."' align='left' /><b>" . $row['code'] . " - ". $row['name'] . "</b><br /><br />" . $row['description'];
$display_accessories.= "<br /><br /><br /><br /><br /><br /><br /><br /></div>";
}
Can anyone help?
Been banging my head against screen all day.
I have created a small search engine for my site but it doesnt seem to display properly.
http://www.hobao-racing.com/accessories2.php
The above link shows everything that it currently in the database. If, for example, I search for 'starter box' it only shows 1 result instead of 2, and there are clearly 2 starter boxes at the bottom of the list.
It seems to do this for a few items I search for but I can't figure out why.
this is the code I have used:
$search = $_POST["search"];
$category = $_POST["category"];
if (!empty ($search)){
$result = mysql_query("SELECT * FROM accessories WHERE code LIKE '%$search%' OR name LIKE '%$search%' OR description LIKE '%$search%'")
or die(mysql_error());
$row = mysql_fetch_array($result);
$total = mysql_num_rows($result);
if($total!='0') {
while($row = mysql_fetch_array($result)){
$display_accessories.= "<div><hr width='95%' /><br />" . "<img style='margin:0px 15px;' src='products/accessories/" . $row['category'] . "/" .$row['code'] . "/thumb.jpg' alt='". $row['name'] ."' align='left' /><b>" . $row['code'] . " - ". $row['name'] . "</b><br /><br />" . $row['description'];
$display_accessories.= "<br /><br /><br /><br /><br /><br /><br /><br /></div>";
}
} else
{
$display_accessories.= "No results to display";
}
}
else{
$result = mysql_query("SELECT * FROM accessories ORDER BY code")
or die(mysql_error());
$row = mysql_fetch_array($result);
}
while($row = mysql_fetch_array($result)){
$display_accessories.= "<div><hr width='95%' /><br />" . "<img style='margin:0px 15px;' src='products/accessories/" . $row['category'] . "/" .$row['code'] . "/thumb.jpg' alt='". $row['name'] ."' align='left' /><b>" . $row['code'] . " - ". $row['name'] . "</b><br /><br />" . $row['description'];
$display_accessories.= "<br /><br /><br /><br /><br /><br /><br /><br /></div>";
}
Can anyone help?