You are here: Re: php/mySQL search/mysql_num_rows() error « All PHP « IT news, forums, messages
Re: php/mySQL search/mysql_num_rows() error

Posted by Chris on 06/14/06 17:13

Hi,

I will give this a try, but FYI - the db doesn't accept duplicates, this is
apparently an issue with the code itself. I have seen the same problem with
this search code referred to on different forums, and it may be that the
problem is with 'DISTINCT', and I will also look at other solutions that
have been posted. As usual, my current priority has switched to something
else, but will be concentrating on this again very soon and will let you
know how it all worked for me.

Thanks,
Chris

"J.O. Aho" <user@example.net> wrote in message
news:4f8963F1hm0qtU1@individual.net...
>
> I wouldn't have done my code the way as it's in the page you have and to
> avoid duplicates you shouldn't use PHP filtering but tell the SQL server
> to give you distinct results (in the first place you should make the
> database to not accept duplicates and you never will have this trouble).
>
> Think the following sql query would fix the trouble:
>
> SELECT DISTINCT(*) FROM links WHERE pageURL LIKE '%$trimm%' OR
> pageDesc LIKE '%$trimm%' OR pageTitle LIKE '%$trimm%' ORDER BY pageLink
> DESC
>
> Here is the code I don't like:
> $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[ 'pageID' ];
> }while( $row= mysql_fetch_array($numresults));
> } //end foreach
>
>
> Here is how I would have done the same:
> while($row= mysql_fetch_array($numresults)) {
> $adid_array[] = $row[ 'pageID' ];
> }
>
>
>
> Think you can modify the
>
> <?php echo $linkhigh; ?><br>
>
> to include the anchor tag, as I'm not sure what data is stored where in
> the table, I'm not completely sure and in the first place I wouldn't use a
> load of preg_replace() when you can use a simple string to make all this.
>
>
>
> The from uses GET and not POST, which makes $_POST['q'] always be unset,
> either use $_GET['q'] or $_REQUEST['q'] (the later don't care if it comes
> from get, post or cookie).
>
>
>
> //Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация