Same ID Submitting
Posted 05 October 2003 - 05:08 PM
I have a database setup for a CD review script, which will have the track listings in it. I also have a web-based update sytem that allows you to enter in the track info using forms. The best way I could think to make this work was to have a page to ask how many tracks you wanted then it generates another page with that many fields, which you can use to fill in the track information. The problem I found was when I got to the submit part. The CD information and the track information have two seperate tables and the track table has three main columns: The album ID (which matches the album ID of the other table), the track number, and the track title. Now I want it to, when you click submit, to submit each field into the database with the same album ID, accending track numbers, and the titles. I\'m completely lost on how to do this all in one submit. I\'m sure this is a simple SQL code, but I cant seem to come up with it.
I guess that\'s all I have to say for now. Thanks for at least reading my post. :wink:
Posted 06 October 2003 - 02:05 PM
what you want to do is on the page submitting, first insert the album and then right after that
$newcd = mysql_insert_id();
will get the id of the last insert
then you can use that id to insert the track info
Posted 06 October 2003 - 08:07 PM
Posted 06 October 2003 - 08:09 PM
Posted 06 October 2003 - 08:15 PM
Posted 06 October 2003 - 08:17 PM
Posted 01 December 2003 - 01:45 AM
album_id | track_numb | track_title
and then I have another table that has all the other album info. So the album_id coresponds to an album_id in that table and is therefore the same for all the tracks on that album. I cant seem to figure out, though, how to input that properly, all from one submit of a form (with all the tracks). I was thinking I might need an auto incremented track_id, but I\'m not sure how to implement that so it helps with my script.
What I have tried is to have the whole form just INSERT into the table with this code:
INSERT INTO album_tracks (album_id,track_numb,track_title) VALUES (\'$record\',\'$track_number\',\'$track_title\')but it appears that it just puts in the last row in the form (which would have the highest track number).
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users