Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2008-06-26, 05:08 AM
Junior Member
 
Join Date: Jun 2008
Posts: 2
spiceydog is on a distinguished road
Default Inserting multiple lines into table

I hope this makes since because I am very confused right now about what I am asking:
I have a website that is for bands to upload and post there songs and such. Right now I am working on the part where you fill out the information for your album to be viewed. So first you have to understand how my table is layed out:
id ¦ album ¦ artist ¦ track ¦ length

So on the page that a user will fill out in order to post there data there will be forms for each of these variables. BUT! There is 5 forms for the track variable because I am expecting people to be uploading entire albums rather than single songs. Now what needs to happen is PHP needs to create 5 lines of data (maybe more or less depending on the size of the album) for the tracks. I don't know if it is a problem but each track form has to have the same value in order for it to correspond to the right place on the MySQL table.

Thanks in advance!
Reply With Quote
  #2 (permalink)  
Old 2008-08-11, 11:42 AM
Member
 
Join Date: Jun 2006
Posts: 55
flann is on a distinguished road
Default

Based on the title of your post, it sounds like you're looking for something like this.

insert into tablename (id, album, artist, track, length)
values
(1, 'meteora', 'linkin park', 'Easier to run', '4:56'),
(2, 'meteora', 'linkin park', 'Faint', '3:34'),
(3, 'Hybrid Theory', 'linkin park', 'With you', '5:34');

It would be better for the long run for you to break up your data into multiple tables though and use joins to combine them when needed.

You should have an artist table, an album table with the artist id as a key and a tracks table with album id as a key. This way you'll reduce the amount of redundant data.
__________________
flann
Free Mortgage Calculator | Debt Free
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:35 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.