if the number of search words is four, the order is displayed 4 then 3 then 2 and last 1.
//Sort array in descending order of the key value arsort($contArray,SORT_DESC);
$FoundRef
.
<?php
//declare an array to store the results
$FoundRef=array();
while(list(
$contentId,$occurances)=each($contArray)){
$aQuery = "select contid,title,left(abstract,200) as summary from content where contid = " . $contentId;
$aResult = mysql_query($aQuery);
if(
mysql_num_rows($aResult) > 0){
$aRow = mysql_fetch_array($aResult);
$FoundRef[] = array (
"contid" => $aRow["contid"],
"title" => $aRow["title"],
"summary" => $aRow["summary"],
"occurance"=>$occurances
);
}//end of if
}
?>
<?php
if(isset($FoundRef))
{
echo "<table width="100%"><tr><th class="title">Search Result</td></tr></table>";
echo "<a href="#" onclick="history.back()">Back</a>";
echo "<br />";
echo sizeof($FoundRef);
echo (sizeof($FoundRef) == 1 ? " reference" : " references");
echo " found";
echo "<p>";
if($junkWords){
echo "Common words like";
foreach($junkWords as $jWords){
echo " "."'".$jWords."'";
}
echo "are removed from the search string";
}
echo "</h5>";
foreach($FoundRef as $a => $value)
{
echo "<table>";
echo "<tr><td valign="top">";
// echo $FoundRef[$a]["contid"];
?>
<a href="showref.php?refid=<?php echo $FoundRef[$a]["contid"]?>"><emp><b><?php echo $FoundRef[$a]
["title"]?></b></emp></a><div align="right"> Occurance(s): <?php echo $FoundRef[$a]["occurance"] ?></div>
<br /><small><?php echo $FoundRef[$a]["summary"] ?>...</small><br /><br />
<?php echo "</td></tr>";
echo "</table>";
}
}//end of isset FoundRef
?>