| bbaros |
| Resourceful |

 |
| |
| Joined: Jul 03, 2005 |
| Posts: 81 |
| Location: Nashville, TN |
|
|
 |
 |
 |
|
I am working on part of a search engine and the results aren't comming back the way i want them to . I wish for it to display the banners not the catagories they are in. can any1 help me. here is the part of the code
I want the $query to look in the description of the link and when it finds a match the banner that is associated with it will be displayed.
Here is my test page I currently only have 3 banners in it at the time. an easy result for the search would be the word "ink" or "hosting" Please help
http://www.infinity-plus.com
I've created it into a module and block so its under GABASE the Banner Search Please help me be able to display the proper results.
THank you.
| Code: | /////////////////////////////////////////////////////////////////SEARCH ENGINE////////////////////////////////////////
function search($query, $min, $orderby, $show) {
global $prefix, $db, $admin, $bgcolor2, $module_name;
include("l_config.php");
include("header.php");
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$Bannerresults;
if(isset($orderby)) {
$orderby = convertorderbyin($orderby);
} else {
$orderby ="hits DESC";
//$orderby = "title ASC";
}
if ($show!="") {
$Bannerresults = $show;
} else {
$show=$Bannerresults;
}
$query = check_html($query, html);
$query = addslashes($query);
if(!is_numeric($Bannerresults) AND $Bannerresults==0)
{
$Bannerresults=10;
}
$result = $db->sql_query("SELECT lid, cid, sid, title, url, imgurl, desciption, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_gabase where title LIKE '%$query%' OR description LIKE '%$query%' ORDER BY $orderby LIMIT ".intval($min).",$Bannerresults");
$fullcountresult = $db->sql_query("SELECT lid, title, imgurl, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_gabase where title LIKE '%$query%' OR description LIKE '%$query%'");
$totalselectedBanner = $db->sql_numrows($fullcountresult);
$nrows = $db->sql_numrows($result);
$x=0;
$the_query = stripslashes($query);
$the_query = str_replace("\'", "'", $the_query);
menu(1);
echo "<br>";
OpenTable();
if ($query != "") {
if ($nrows>0) {
echo "<font class=\"option\">"._SEARCHRESULTS4.": <b>$the_query</b></font><br><br>";
// ."<table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"option\"><b>"._USUBCATEGORIES."</b></font></td></tr></table>";
$result2 = $db->sql_query("SELECT cid, title from ".$prefix."_gabase_categories where title LIKE '%$query%' ORDER BY title DESC");
while ($row2 = $db->sql_fetchrow($result2)) {
$cid = intval($row2['cid']);
$stitle = stripslashes(check_html($row2['title'], "nohtml"));
$res = $db->sql_query("SELECT * from ".$prefix."_gabase where cid='$cid'");
$numrows = $db->sql_numrows($res);
$row3 = $db->sql_fetchrow($db->sql_query("SELECT cid,title,parentid from ".$prefix."_gabase_categories where cid='$cid'"));
$cid3 = intval($row3['cid']);
$title3 = stripslashes(check_html($row3['title'], "nohtml"));
$parentid3 = intval($row3['parentid']);
if ($parentid3>0) $title3 = getparent($parentid3,$title3);
$title3 = ereg_replace($query, "<b>$query</b>", $title3);
echo "<strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&l_op=viewlink&cid=$cid\">$title3</a> ($numrows)<br>";
}
/////////////////////////////////////////////////////////MOD RESULTS/////////////////
//echo "<br><table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"option\"><b>"._Banner."</b></font></td></tr></table>";
$orderbyTrans = convertorderbytrans($orderby);
//echo "<br><font class=\"content\">"._SORTBannerBY.": "
//echo "<br><font class=\"content\">"._TITLE." (<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=titleA\">A</a>\<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=titleD\">D</a>)"
//.""._DATE." (<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=dateA\">A</a>\<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=dateD\">D</a>)"
//.""._RATING." (<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=ratingA\">A</a>\<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=ratingD\">D</a>)"
//.""._POPULARITY." (<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=hitsA\">A</a>\<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&orderby=hitsD\">D</a>)"
//."<br>"._SITESSORTED.": $orderbyTrans<br><br>";
//echo "<br><br>";
while($row = $db->sql_fetchrow($result)) {
$lid = intval($row['lid']);
$cid = intval($row['cid']);
$sid = intval($row['sid']);
$title = stripslashes(check_html($row['title'], "nohtml"));
$url = stripslashes($row['url']);
$imgurl = stripslashes($row['imgurl']);
$description = stripslashes($row['description']);
$time = $row['date'];
$hits = intval($row['hits']);
$linkratingsummary = $row['linkratingsummary'];
$totalvotes = intval($row['totalvotes']);
$totalcomments = $row['totalcomments'];
$linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
$transfertitle = str_replace (" ", "_", $title);
$title = ereg_replace($query, "<b>$query</b>", $title);
/////////////MOD POINT 9996//////////////
//echo "<a href=\"modules.php?name=$module_name&l_op=visit&lid=$lid\" target=\"new\"><b>$title</b></a><br>";
//echo "<img src=\"$imgurl\"> "._HITS.": $hits";
newlinkgraphic($datetime, $time);
popgraphic($hits);
$description = ereg_replace($query, "<b>$query</b>", $description);
// echo ""._DESCRIPTION.": $description<br>";
setlocale (LC_TIME, $locale);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
$datetime = strftime(""._BannerDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
$datetime = ucfirst($datetime);
//echo ""._HITS.": $hits";
//echo ""._ADDEDON.": $datetime "._HITS.": $hits";
/* voting & comments stats */
if ($totalvotes == 1) {
$votestring = _VOTE;
} else {
$votestring = _VOTES;
}
if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
// echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
}
//echo "<br><a href=\"modules.php?name=$module_name&l_op=ratelink&lid=$lid&ttitle=$transfertitle\">"._RATESITE."</a>";
if ($totalvotes != 0) {
// echo " | <a href=\"modules.php?name=$module_name&l_op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
}
if ($totalcomments != 0) {
// echo " | <a href=\"modules.php?name=$module_name&l_op=viewlinkcomments&lid=$lid&ttitle=$transfertitle>"._SCOMMENTS." ($totalcomments)</a>";
}
detecteditorial($lid, $transfertitle);
//echo "<br>";
$row4 = $db->sql_fetchrow($db->sql_query("SELECT cid,title,parentid from ".$prefix."_gabase_categories where cid='$cid'"));
$cid3 = intval($row4['cid']);
$title3 = stripslashes(check_html($row4['title'], "nohtml"));
$parentid3 = intval($row4['parentid']);
if ($parentid3>0) $title3 = getparent($parentid3,$title3);
//echo ""._CATEGORY.": $title3<br><br>";
$x++;
}
//echo "</font>";
$orderby = convertorderbyout($orderby);
} else {
echo "<br><br><center><font class=\"option\"><b>"._NOMATCHES."</b></font><br><br>"._GOBACK."<br></center>";
}
/* Calculates how many pages exist. Which page one should be on, etc... */
$linkpagesint = ($totalselectedBanner / $Bannerresults);
$linkpageremainder = ($totalselectedBanner % $Bannerresults);
if ($linkpageremainder != 0) {
$linkpages = ceil($linkpagesint);
if ($totalselectedBanner < $Bannerresults) {
$linkpageremainder = 0;
}
} else {
$linkpages = $linkpagesint;
}
/* Page Numbering */
if ($linkpages!=1 && $linkpages!=0) {
echo "<br><br>"
.""._SELECTPAGE.": ";
$prev=$min-$Bannerresults;
if ($prev>=0) {
echo " <b>[ <a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&min=$prev&orderby=$orderby&show=$show\">"
." << "._PREVIOUS."</a> ]</b> ";
}
$counter = 1;
$currentpage = ($max / $Bannerresults);
while ($counter<=$linkpages ) {
$cpage = $counter;
$mintemp = ($perpage * $counter) - $Bannerresults;
if ($counter == $currentpage) {
echo "<b>$counter</b> ";
} else {
echo "<a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
}
$counter++;
}
$next=$min+$Bannerresults;
if ($x>=$perpage) {
echo " <b>[ <a href=\"modules.php?name=$module_name&l_op=search&query=$the_query&min=$max&orderby=$orderby&show=$show\">"
." "._NEXT." >></a> ]</b>";
}
}
} else {
echo "<center><font class=\"option\"><b>"._NOMATCHES."</b></font></center><br><br>";
}
CloseTable();
include("footer.php");
} |
|
|