User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,011 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,568 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 437 | Replies: 3
Reply
Join Date: Jun 2008
Location: Upstate, NY
Posts: 38
Reputation: PomonaGrange is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
PomonaGrange PomonaGrange is offline Offline
Light Poster

AutoSuggest textbox

  #1  
Jul 18th, 2008
Hey All, I am trying to write a php script and would like to have an autosuggest text box with data from a mysql database. This would be for designating a town in a form.
The sql query I would use would be.

$sql = "SELECT DISTINCT `Town` FROM '".$Table_Name."' ";

Then there would be a second autosuggest text box that would only select cemeteries in the town from the first box.

I have found a few tutorials on the web but can't seem to get them to work with a sql query.

Does anyone have any suggestions???
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Adelaide, South Australia
Posts: 383
Reputation: darkagn will become famous soon enough darkagn will become famous soon enough 
Rep Power: 3
Solved Threads: 44
darkagn's Avatar
darkagn darkagn is offline Offline
Posting Whiz

Re: AutoSuggest textbox

  #2  
Jul 18th, 2008
Your syntax is not quite right in the SQL statement. You don't need so many quote marks. This will work for you I believe:
  1. $sql = "SELECT DISTINCT Town FROM $Table_Name";
Then you actually need to run the query. What I normally do is use the PDO library to connect to a MySQL database, but there are other ways of doing it too. Here is a link to the PDO documentation. If you have trouble connecting to your database or running the query, repost and will try to help.
The answer is 42.
Reply With Quote  
Join Date: Jun 2008
Location: Upstate, NY
Posts: 38
Reputation: PomonaGrange is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
PomonaGrange PomonaGrange is offline Offline
Light Poster

Re: AutoSuggest textbox

  #3  
Jul 18th, 2008
I guess I should stress that I havn't got a script working yet. Could you reccomend a script to use?
I am not familiar with the PHP PDO library so I am hesitant to use it. I can get the sql query to work ok for echoing to a html based page, but I cant get it to work with a autosuggest text box. The script that I have been trying to use is HERE

Right now I use the following definitions to connect to the database.

$server //this is the host server not localhost on my server

$dbusername //the user name

$dbpassword //the password

$db_name // the name of the database

I thought this might help if someone can get a script working. I would appreciate it if you or anyone could help.
Reply With Quote  
Join Date: Jun 2008
Location: Upstate, NY
Posts: 38
Reputation: PomonaGrange is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
PomonaGrange PomonaGrange is offline Offline
Light Poster

Re: AutoSuggest textbox

  #4  
Jul 20th, 2008
just to let you know. I did try the sql statement that you posted and it still didn't work.
I could get the script woking with a static list from the example, but when I changed things to use the sql it won't work.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC