Page 1 of 1

select distinct like problems

Posted: Mon Mar 31, 2008 2:56 am
by real246
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


this is my code: it's a search suggest type feature. I'm using the javascript alert() command to display what this returns. This code here returns quotation marks if it find something in the database, otherwise it returns nothing. i can't get it to display what it really is finding.

Code: Select all

if (isset($_GET['search']) && $_GET['search'] != '') {
    $search = addslashes($_GET['search']);
    $suggest_query = db_query("SELECT distinct payee FROM transactions WHERE payee like '%".$search."%'  ORDER BY payee");
    while($suggest = db_fetch_array($suggest_query)) {
        echo $suggest['suggest'] . "\n";
    }
}
My php knowledge is patchy at best.
Any help is greatly appreciated.


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: select distinct like problems

Posted: Mon Mar 31, 2008 3:58 am
by Inkyskin
echo $suggest['suggest'] should be echo $suggest['payee'] in your example