Jump to content

Recommended Posts

Hi all,

 

how would you upload track information into a database? Obvioulsy the amount of tracks will vary per album uploaded and I was wondering the best way to acheive this.

 

The end result being that I would like to echo out the information like:

 

1. Track 1 name
2. Track 2 name etc

 

The only uploading I have done has just been through a PHP form and then inserting it into a database.

 

How would you go about this?

 

Thanks

I am happy with the insert, but i dont know how the best way to do this for tracks is. If I basically call each field say t1 for track one and then t2 for track two etc, it is going to cause problems with undefied fields if i have 20 boxes but there are only 12 tracks, i would in effect have undefied fields on t13 to t20 if you see what I mean

I would have JavaScript operate the number of input boxes. But you can always check using PHP to see if the input box is empty or not.

 

This is how I would do it:

<form method="post" name="tracks">
<input id="1" type="hidden" name="tracks_count" value="0" />
</form>

<script type="text/javascript">
var trackcount = 1;
var trackform = document.forms.tracks;
function addTrackField () {
     trackform.innerHTML += '<input type="text" name="track' + trackcount + '" />';
     trackform.tracks_count.value = ((int) trackform.tracks_count.value) + 1;
     trackcount++;
}
<script>

<a href="javascript:addTrackField(); return false;">Add track</a>

 

Then for PHP, I can grab the tracks_count field and loop.

you could store them as CSV's. In just one column.

So say CD TITLE, CD TRACKS. and thats it.

 

Then store them by appending a comma in between each track name. All you then have to do to find out the number of tracks is split them using explode().

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.