/    Sign up×
Community /Pin to ProfileBookmark

Why does this duplicate?

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>1</b>” , $row_linkcat[ ‘store_name’ ] );

foreach($trimmed_array as $trimm){
if($trimm != ‘b’ ){

$titlehigh = preg_replace( “‘($trimm)’si” , “<b>1</b>” , $titlehigh);
}
//end highlight

[/QUOTE]

I appreciate anyones help

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@sac8513authorDec 16.2007 — any ideas?
Copy linkTweet thisAlerts:
@sac8513authorDec 17.2007 — please i can really use the help..
×

Success!

Help @sac8513 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...