Apr 12, 2005
I'm not one who likes to ask for help, so for the last three days my brain has been turning to mush while I try to create a DJ Request Song Wish List. Anyone who can help me out will be saving me from severe insanity. :)
View 1 Replies
My goal is to:
1. Display search results for song title, artist and genre. (accomplished)
2. Allow the user to add songs to their Wish List. This is done by displaying checkboxes with the corresponding value equal to the songID. (working on it)
3. Allow the user to update their wishlist by adding/deleting songs.
So far I have a form that retrieves the song info from a database in a repeating region. In Dreamweaver:
<input name="songID" type="checkbox" id="songID" value="<b><?php echo $row_RecordsetSearchResults['Title'];?></b> by <?php echo $row_RecordsetSearchResults['Artist'];?>">
This puts the corresponding songID number into a checkbox value, which in turn is submitted by form POST action to the following page as an array.
To process this array I have:
$songID = $_POST['songID'];
print '<p>Song IDs:</p>'
// process items
$n = count($songID);
for($i = 0; $i <= $n; $i++)
//See if the values are being passed from POST
$songsInsert = '*'.implode('*',$_POST['songID']).'<br>'
$insertSQL = sprintf("INSERT INTO wishlist (Username, Title) VALUES (%s, %s)",
$Result1 = mysql_query($insertSQL, $ToneDeaf) or die(mysql_error());
The problem is, I'm using implode. It does store the songs, but only as one long block of text. So if the user picks "New York by Frank Sinatra" and "Hot In Here by Nelly" it is stored as "*New York by Frank Sinatra*Hot In Here by Nelly*" Obviously this gives me no options to make this actually readable, let alone allow the user to remove one of those songs from their list (both would be have to be removed.)
Also, referencing only the songID number as stored in the music database doesn't seem a good option, since the song database will be changing frequently and song data may be overwritten. Not sure if there's a viable workaround there.
Originally I wanted to store Title, Artist, Genre under seperate columns so I could link them to something like "See more songs from this Artist." However the more I read about arrays and multidimensional arrays, I realize I'm not ready to go there yet. (I just started learning PHP two weeks ago.)