•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,640 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 3,161 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: 414 | Replies: 3
![]() |
•
•
Join Date: Jun 2008
Location: Upstate, NY
Posts: 38
Reputation:
Rep Power: 1
Solved Threads: 1
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???
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???
•
•
Join Date: Aug 2007
Location: Adelaide, South Australia
Posts: 381
Reputation:
Rep Power: 3
Solved Threads: 43
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:
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.
php Syntax (Toggle Plain Text)
$sql = "SELECT DISTINCT Town FROM $Table_Name";
The answer is 42.
•
•
Join Date: Jun 2008
Location: Upstate, NY
Posts: 38
Reputation:
Rep Power: 1
Solved Threads: 1
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.
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- autosuggest textbox with java from database (JSP)
- require code (Java)
Other Threads in the PHP Forum
- Previous Thread: 2 fields won't update in mysql db
- Next Thread: Multidimensional array problem


Linear Mode