i think need some advanced help with a search script
Posted: Mon Jun 10, 2002 8:29 pm
many search engines have a thing where u can click on a number to jump ahead. I was wondering what i should add to make that work for me. I think it has somthing to do with limit. PLEASE HELP!!!
here is my code:
here is my code:
Code: Select all
<?
$page += 1;
$tempCount = $page*10;
$old+=10;
trim($searchBy);
mysql_connect("localhost");
mysql_select_db("Ads");
$query1="select * from user_Ads where $searchBy like '%$keywords%'";
$results1=mysql_query($query1);
$query = "select * from user_Ads where $searchBy like '%$keywords%' order by $searchBy desc limit $old,$numResultsPP";
$result = mysql_query($query);
$num_results = mysql_num_rows($results1);
$number_cols = mysql_num_fields($result);
if($num_results==0){
echo "<table bgcolor=#e1e1e1><tr><td>Your search for <b>$keywords</b> returned <b>0</b> results.</td></tr></table>";
}
else {
echo "<table bgcolor=#e1e1e1><tr><td>Your search for <b>$keywords</b> returned <b>$num_results</b> results.</td></tr></table>\n\n";
echo "<br><form name=form1 action=$PHP_SELF method=post>\n<input type='hidden' name='resultCount' value=$tempCount>\n<input type='hidden' name='page' value=$page><input type='hidden' name='searchBy' value=$searchBy>\n<input type='hidden' name='old' value=$old>\n<input type='hidden' name='numResultsPP' value=$numResultsPP>\n<input type='hidden' name='keywords' value=$keywords>\n";
if($num_results>=1 && $num_results - ($page * 10) > 0 && $page!=1){
echo "<a href='javascript:history.go(-1)'><--Prev</a>";
echo "<a href='javascript:document.form1.submit()'>Next--></a>\n</form><br>\n";
}
elseif($num_results>=1 && $num_results - ($page*10) <= 0) {
echo "<a href='javascript:history.go(-1)'><--Prev</a></form>\n";
}
else{
echo "<a href='javascript:document.form1.submit()'>Next--></a>\n</form>\n";
}
}
while ($row = mysql_fetch_row($result)) {
$resultCount += 1;
echo "<table border=0 width=900 cellpadding=0 cellspacing=0>\n";
for($i=0;$i<$number_cols;$i++){
echo "<tr><td bgcolor='#004080'><center><span style='color:#ffffff;width:100%'><b>Part:</b>$rowї7] $rowї9] $rowї8]--><b>Category:</b> $rowї6]</span></center></td></tr>";
echo "<tr bgcolor=#e1e1e1>\n";
echo "<td>";
echo "<b>$resultCount</b>. $rowї2], $rowї1]<blockquote>$rowї10]<br><b>E-mail:</b> <a href='mailto:$rowї3]'>$rowї3]</a><br><b>Phone:</b> $rowї4] <b>Fax:</b> $rowї5]<br>";
$i = 11;
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>";
echo "<br><br>";
}
?>