Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox List Form for Website? 1

Status
Not open for further replies.

pkirill

Technical User
Jun 15, 2002
134
US
I've got a client who is a party DJ and would like to put a form on her website that will allow clients to preselect the music they want to listen to during their party. Ideally it would work that the client checks the box next to the song(s) then clicks a Submit button and a list of the selected songs is emailed to the DJ. She currently has all the songs in an excel spreadsheet.

I was wondering if anyone knew of a package out there that would let her convert this spreadsheet (or exported CSV) to a check list html form - PHP preferred. She's not thrilled with the idea of having to recode over 900 songs into PHP by hand...

Thanks for any help!
 
Use php to edit the csv, or notepad or perl or any number of fine editors.
Upload the spreadsheet to mysql and serve up dynamic pages...
The possibilities are myriad.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Ahhh... I believe you have mistaken me for someone who knows what they are doing with PHP... [dazed]

What I need is a program (if one even exists) that will suck the song names from an xls or csv and populate a php document with the appropriate code for a check list/email form. I've seen programs like FormMail that will create a form template - which is half the battle, but with over 900 songs that change all the time adding to this template would be problematic. So I continue the search for my php grail.

Thanks!
 
Thanks, johnwm.

I appreciate the pointers. I've googled for days, scoured many a code site (not just php), and was unable to find what I was looking for. I came to this forum in hopes that a design guru may have come across something I missed. I sincerely do appreciate anyone taking time to help out - I just wanted folks to know I didn't pick this forum at random.

It's true I'm looking for a fish, but only because I have proven to myself that I am a lousy fisherman in this endeavor...

Thanks again!
 
Hi

I post a very simple PHP solution here, but for further improvement you will get more help in forum434 ( PHP ).
Code:
[highlight antiquewhite]   music.csv              [/highlight]
1	One	First	one-first.mp3
2	Two	Second	two-second.mp3
3	Three	Third	three-third.mp3


[highlight antiquewhite]   musiclist.php          [/highlight]
<html>
<body>
<form [green]action[/green]=[maroon]"musicsend.php"[/maroon]>
<table [green]border[/green]=[maroon]"1"[/maroon]>
<tr><th>I want it</th><th>Title</th><th>Artist</th></tr>
[highlight #eee]<?php
[teal]$FIL[/teal]=fopen([maroon]"music.csv"[/maroon],[maroon]"r"[/maroon]);
[b]while[/b] ([teal]$lin[/teal]=fgetcsv([teal]$FIL[/teal],0,[maroon]"\t"[/maroon])) {
  echo [maroon]"<tr><td><input type=\"checkbox\" name=\"nr[]\" value=\"[/maroon][teal]$lin[0][/teal][maroon]\"></td><td>$lin[2]</td><td>$lin[1]</td></tr>\n"[/maroon];
}
fclose([teal]$FIL[/teal]);
?>[/highlight]
</table>    
<input [green]type[/green]=[maroon]"submit"[/maroon] [green]value[/green]=[maroon]"Send selection list"[/maroon]>
</form>
</body>
</html>


[highlight antiquewhite]   musicsend.php          [/highlight]
<html>
<body>
[highlight #eee]<?php
[teal]$lis[/teal]=[teal]$_GET[nr][/teal];
[teal]$mess[/teal]=[maroon]"Prepare the following files : "[/maroon];
echo [maroon]"You sent a list of "[/maroon],count([teal]$lis[/teal]),[maroon]" melodies :<br>\n"[/maroon];
[b]if[/b] ([teal]$lis[/teal]) {
  echo [maroon]"<ol>\n"[/maroon];
  [teal]$FIL[/teal]=fopen([maroon]"music.csv"[/maroon],[maroon]"r"[/maroon]);
  [b]while[/b] ([teal]$lin[/teal]=fgetcsv([teal]$FIL[/teal],0,[maroon]"\t"[/maroon])) [b]if[/b] (array_search([teal]$lin[0][/teal],[teal]$lis[/teal])!==false) {
    echo [maroon]"<li>[/maroon][teal]$lin[2][/teal][maroon] - [/maroon][teal]$lin[1][/teal][maroon]</li>\n"[/maroon];
    [teal]$mess[/teal].=[maroon]"[/maroon][teal]$lin[3][/teal][maroon], "[/maroon];
  }
  fclose([teal]$FIL[/teal]);
  echo [maroon]"</ol>\n"[/maroon];
  mail([maroon]"you@example.com"[/maroon],[maroon]"Playlist requirement"[/maroon],[teal]$mess[/teal]);
}
?>[/highlight]
</body>
</html>

Feherke.
 
That's really great. Thanks feherke! I've been able to make a few modifications but still have a few tweaks I need to do - it works great with up about 45 songs, but if you select more than that, the submit button doesn't seem to work. But I'll follow up in the PHP forums.

Thanks again for the 'fish'!
 
Hi

Then in the musiclist.php add [tt]method="post"[/tt] attribute to the [tt]form[/tt] tag, and in the musicsend.php change the [tt]$_GET[/tt] to [tt]$_POST[/tt] :
Code:
[highlight antiquewhite]   musiclist.php          [/highlight]
<form [green]action[/green]=[maroon]"musicsend.php"[/maroon] [green]method[/green]=[maroon]"post"[/maroon]>


[highlight antiquewhite]   musicsend.php          [/highlight]
[highlight #eee][teal]$lis[/teal]=[teal]$_POST[nr][/teal];[/highlight]

Feherke.
 
That certainly nailed it! Thanks again for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top