The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Drop down menu with php

Hello,

I'm pulling classes from a database and displaying them in dropdown boxes for the users to choose from. I need to be able to take the courseIDs(in my database) from the courses they pick and store them into a table called account_courses. I also wanted the drop-down boxes to start out blank so if they didn't want to add a class in that box they didn't have to. I'm not sure how to implement the variables so I can take in the courseID with accountID. Here is my code:

Thank you so much. That really helped. I'm still having some problems though. I have 3 tables: accountInformation, courses, and account_courses. I made the table account_courses to clear up a many to many. I can't seem to figure out how to write to it though.

Ok I see. I'm new to using php and mysql. I would really like to have the course name be a link that takes you to that specific course page but i'm not sure how to associate the name of the course with a link. Also what did you mean about looping though earlier?

You will have one row in this table per course the user is registered to. You need a loop to retrieve all of the rows you selected. Your current code only retrieves the first row, which will only give you one course they're registered for.

name: query
description: connects to a given database stored in the DBADDRESS constant, executes a given query,
closes the database, and returns the result of the query as an array
parameters: 1. $query -- a valid SQL query
return: $result -- query results in an array

Ok.. There are only a couple of things that I need help with. When I display the courses from the database, the first course I add to my course database never shows up. The rest of the entries do after the 1st one. How can I correct this.

Another question I had was how I could make all of my course pages into links with the courseID. So the user could just click their class and be taken to the page. I wasn't sure how to to echo "<li>" . $row['courseName'] . "<br /></li>"; change it so I could see links to every class.

Ok that worked but when I try to click add a course or create course page it just says: we have no data. When I take the else out it say undefined variable. The accountIDs are still being put in the url so I have no idea why its happening.