real_escape_string($_POST['queryString']); // Is the string length greater than 0? if(strlen($queryString) >0) { $query = $db->query("SELECT * FROM search s INNER JOIN categories c ON s.cat_id = c.cid WHERE name LIKE '%" . $queryString . "%' ORDER BY cat_id LIMIT 8"); if($query) { // While there are results loop through them - fetching an Object. // Store the category id $catid = 0; while ($result = $query ->fetch_object()) { if($result->cat_id != $catid) { // check if the category changed echo ''.$result->cat_name.''; $catid = $result->cat_id; } echo ''; echo ''; $name = $result->name; if(strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; } echo ''.$name.''; $description = $result->desc; if(strlen($description) > 80) { $description = substr($description, 0, 80) . "..."; } echo ''.$description.''; } echo 'Nothing interesting here? Try the sitemap.
'; } else { echo 'ERROR: There was a problem with the query.'; } } else { // Dont do anything. } // There is a queryString. } else { echo 'There should be no direct access to this script!'; } } ?>