select distinct like problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
real246
Forum Newbie
Posts: 3
Joined: Mon Mar 31, 2008 2:50 am

select distinct like problems

Post 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.
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: select distinct like problems

Post by Inkyskin »

echo $suggest['suggest'] should be echo $suggest['payee'] in your example
Post Reply