I am reposting this and need serious help…
If a store name is searched that has more than one word, the amount of results that i get equals the amount of words in the name.
For instance if i search “Justins Hardware” this is the search result:
Justins Hardware
Justins Hardware
but if i just search “Justins” I appropriately get:
Justins Hardware
Here is the part of the code that I believe has the issues
[QUOTE]
$query .= ” LIMIT $s,$limit” ;
$numresults = mysql_query ($query) or die ( “Couldn’t execute query” );
$row= mysql_fetch_array ($numresults);
//store record id of every item that contains the keyword in the array we need to do this to avoid display of duplicate search result.
do{
//EDIT HERE and specify your field name that is primary key
$adid_array[] = $row[ ‘store_name’ ];
}while( $row= mysql_fetch_array($numresults));
} //end foreach
if($row_num_links_main == 0 && $row_set_num == 0){
$resultmsg = “<p>Search results for:” . $trimmed .”</p><p>Sorry, your search returned zero results</p>” ;
}
//delete duplicate record id’s from the array. To do this we will use array_unique function
$tmparr = array_unique($adid_array);
$i=0;
foreach ($tmparr as $v) {
$newarr[$i] = $v;
$i++;
}
// now you can display the results returned. But first we will display the search form on the top of the page
?>
<form action=”test.php” method=”get” name=”search”>
<div align=”center”>
<input name=”q” type=”text” value=” <?php echo $q; ?> ” size=”15″>
<input name=”search” type=”submit” value=”Search”>
</div>
</form>
<?php
// display what the person searched for.
if( isset ($resultmsg)){
echo $resultmsg;
exit();
}else{
echo “Search results for: ” . $var;
}
foreach($newarr as $value){
$query_value = “SELECT * FROM store WHERE store_name = ‘$value'”;
$num_value=mysql_query ($query_value);
$row_linkcat= mysql_fetch_array ($num_value);
$row_num_links= mysql_num_rows ($num_value);
$titlehigh = preg_replace ( “‘($var)’si” , “<b>
foreach($trimmed_array as $trimm){
if($trimm != ‘b’ ){
$titlehigh = preg_replace( “‘($trimm)’si” , “<b>
}
//end highlight
I appreciate anyones help