php mysql drop down list :'(
Moderator: General Moderators
php mysql drop down list :'(
I am trying to read my database from mysql. I have two fields author and books. I need the author field to be in the drop down list and then when I choose an author I need it to display below on the same page all of the books by that author in the database. I don't really know how to use php. I know how to connect the database to php but then I don't know how to get the author from the database to the drop down list and then I am not really sure how to display the books below.
Last edited by peter011 on Tue Mar 06, 2012 4:51 am, edited 1 time in total.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: php mysql drop down list :'(
The code pasted is to create the dropdown menu; paste the code you use to select the books by a specific author from the database.
If you don't use all the fields you shouldn't select *. Select only fields you are going to use.
Code: Select all
$sql="SELECT * FROM tb_lib1, tb_lib2 WHERE tb_lib1.Id = tb_lib2.Id"; “Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: php mysql drop down list :'(
I can't help but think a select list is a bit of an unwieldy solution to this problem. Unless this bookstore caters to an exceptionally small niche market, you're going to have hundreds if not thousands of authors. Wouldn't a simple text input make more sense?
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: php mysql drop down list :'(
interesting point; one reason i can think of (for the list) is that visitors to the site could possibly not know the correct spelling of the author and some visual reminder might help themCelauran wrote:Wouldn't a simple text input make more sense?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering