...

View Full Version : problem with search engine



boeing747fp
11-17-2003, 10:02 PM
i have this code in my search engine and for some reason it just outputs "search returned no results" on everything even when it does return results

if(!empty($row)){
echo "<center>No Results found for your search: <em>$q</em></center>";
}
-----------------------------
the complete code is...
-----------------------------
<?php
if(isset($q)){
$aa = mysql_connect("localhost", "root", "password");
$db = mysql_select_db("search",$aa);
$sql_select = "SELECT * FROM search WHERE keywords LIKE '%$q%'";
$result = mysql_query($sql_select) or die ("Queryproblem: " . mysql_error());

while ($row = mysql_fetch_array($result)) {
echo "<table width='97%' align='center' border='0' bgcolor='#FFFFFF'>";
echo "<tr>";
echo "<td background='ed.gif'><span class='style2'>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;<a href='$row[2]' class='search'><font face='arial' size='2'><b>$row[0]</font></b></a> </span></td>";
echo "</tr>";
echo "<tr>";
echo "<td><span class='style44'><font face='arial' size='2' color='#000099'>$row[1]</font></span></td>";
echo "</tr>";
echo "<tr>";
echo "<td> <span class='style8'>&nbsp;<a href='$row[2]' class='search2'><font face='arial' size='2'><b>$row[4]</font></b></a></span></td>";
echo "</tr>";
echo "</table>";
echo "<br>";
}
if(!empty($row)){
echo "<font face='arial' size='3' color='navy'><center><b>No Results found for your search:</b> <em>$q</em></center></font>";
}
}
?>

Funkel
11-17-2003, 10:36 PM
<?php
if(isset($q)){
$aa = mysql_connect("", "", "");
$db = mysql_select_db("database",$aa);
$sql_select = "SELECT * FROM table WHERE thing LIKE '%$q%'";
$result = mysql_query($sql_select) or die ("Queryproblem: " . mysql_error());

if (mysql_num_rows($result) > 0) {

while ($row = mysql_fetch_array($result)) {
print $row[0];
}; //end fetch

} else {
// no rows returned, no search
echo "<font face='arial' size='3' color='navy'><center><b>No Results found for your search:</b> <em>$q</em></center></font>";
}
}; // end if q
?>

that worked for me



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum