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. I am working on this for a small local bookstore and I really want to incorporate this feature for them.

Well i can help you with that. i have done this many times. if you will post the authors and the books they have, i will make a script for you that you can view on my server in a couple of hours.

Well i can help you with that. i have done this many times. if you will post the authors and the books they have, i will make a script for you that you can view on my server in a couple of hours.

ID Author Title
1 Patricia Cornwell Preditor
2 Patricia Cornwell Cruel and Unusual
3 John Grisham The Client
4 John Grisham The Firm
5 John Grisham The rainmaker
6 James Patterson Violets are blue
7 Sue Grafton A is for Alibi
8 Janet Evanovich One for the money
9 Janet Evanovich Two for the dough

This is just part of the file

can i use more than one table or does it need to be in one? i will also give you code to create the database tables if you need it.

sorry forgot something in the readme file. i have updated it. please download the zip file again.
my bad

I can't get the records to display after I click on an author. I just wanted them displayed under the drop down menu and I am getting duplicates of the authors names.

sorry forgot something in the readme file. i have updated it. please download the zip file again.
my bad

I am also not sure on what you mean by this:

4. INSERT THE SCRIPT IN select.php WHEREVER THE SELECT BOX NEEDS TO BE
DISPLAYED. IF THIS IS NOT WANTED ADD '<?php include 'select.php';?>' THERE INSTEAD.

5. INCLUDE THE javascript.js FILE INTO THE PAGE. OR INCLUDE '<script type="text/javascript" src="javascript.js"></script>' INSTEAD.

I am just confused on where to add these things. and I don't understand what you mean by insert the script in select.php. Do you mean the javascipt?

inside the select.php there is code wraped in <?php ?> tags. put this in your page where you need the drop down list to be displayed.
as for the javascript, you can just but

<script type="text/javascript" src="javascript.js"></script>

in the head of the document.

inside the select.php there is code wraped in <?php ?> tags. put this in your page where you need the drop down list to be displayed.
as for the javascript, you can just but

<script type="text/javascript" src="javascript.js"></script>

in the head of the document.

I have the authors displaying in my drop down list, but I can't get it to display the title underneath the drop down list. I also have duplicate authors in the drop down.

the reason duplicate authors are being displayed is because you entered them into the database more than once. all authors should have once entry in the author field. all of the books associated with the author go in the books field on the same row seperated by commas.

also you have to add the

<span id="books"></span>

where you want the books to be displayed

the reason duplicate authors are being displayed is because you entered them into the database more than once. all authors should have once entry in the author field. all of the books associated with the author go in the books field on the same row seperated by commas.

also you have to add the

<span id="books"></span>

where you want the books to be displayed

is the id refering to a variable in the code here? just trying to understant what it means

Hi could I get that code please I have the same problem..thanks in advance..amila

This article has been dead for over six months. Start a new discussion instead.