Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Newbie ( Very New)

Author  Topic 

Dazzer36
Starting Member

1 Post

Posted - 2011-09-16 : 06:12:00
Hi all,
I am very new to SQl, but a keen and quick learner.
What i have is a search bar in my site which i have now autosuggest feature on it, the autosuggest picks up the categorys from my database fine, inputs the data in the input field fine, and when i click search all is fine. But what i would like is the search to read the id of the table not the title
This is the query-
$query = $db->query("SELECT title FROM categories WHERE title LIKE '$queryString%' LIMIT 5");
so in search results it gives me the title ie -
/search_results.php?category=Builders&location=????miles=&submit_search=Search

But i would like it to search like this -
/search_results.php?category=5588=????miles=&submit_search=Search , with the id

Hope this makes sense

Regards
Darren

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-09-16 : 06:22:35
Limit? That's a MySQL keyword, not a SQL Server keyword.

This is a Microsoft SQL Server site. If you're using MySQL (and php) you're much more likely to get useful answers on a MySQL forum. http://forums.mysql.com or http://www.dbforums.com

--
Gail Shaw
SQL Server MVP
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-09-16 : 08:16:31
select ID, title from categories. Display the title, but pass the ID to your variable.
Go to Top of Page
   

- Advertisement -