Hi, Im having a problem with displaying the results from a search. I need to get the results linked to there page on the site but to do this I need to pull data from a few tables in my database. I think that this is the part of the code that is not working. I would be grateful to anyone who can have a look at the code and point me the right way. Thank you.
[php]<?php
require (“header.php”);
require (“connect.php”);
$searching=$_POST[‘searching’];
$find=$_POST[‘find’];
echo’
';
if ($searching ==“yes”)
{
echo “
Results
”;if ($find == “”)
{
echo “You forgot to enter a search term”;
exit;
}
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
echo’ ';
$data = mysql_query(“SELECT * FROM categories WHERE cat_name LIKE’%$find%’ AND cat_website = ‘1’”);
{
while($result = mysql_fetch_array( $data ))
{
echo ’
';
$fg_sql = mysql_query("SELECT * FROM family_group WHERE familygroup_id = " . $result['cat_group'] . "");
{
while($fg_result = mysql_fetch_array( $fg_sql ))
{
echo '';
$gr_sql = mysql_query("SELECT * FROM groups WHERE group_type = " . $fg_result['familygroup_cat'] . "");
{
while($gr_result = mysql_fetch_array( $gr_sql ))
{
echo '';
$ty_sql = mysql_query("SELECT * FROM product_types WHERE type_id = " . $gr_result['group_type'] . "");
{
while($ty_result = mysql_fetch_array( $ty_sql ))
{
echo ' <img border="0" src="images/part/' . $result['cat_image'] . '"><a href="product' . $result['cat_page'] . '.php?url=1&page=' . $result['cat_id'] . '&ty=' . $ty_result['type_id'] . '&gr=' . $gr_result['group_id'] . '&fg=' . $fg_result['familygroup_id'] . '">' . $result['cat_name'] . '</a>';
}
}
}
}
}
}
}
}
echo ’ ';
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo ‘Sorry, but we can not find an entry to match your query
’;
}
}
require (“footer.php”);
?>
[/php]