[SOLVED] Dynamic Checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

kularian
Forum Newbie
Posts: 8
Joined: Mon Mar 05, 2007 12:38 pm

Post by kularian »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


K, got some assistance from a friend of a friend who just happened to be around.  Here's what he did:

Code: Select all

$interests = array();
for($i=0;$i<sizeof($_POST['interests']);$i++) {
	$interests[$i] = $_POST['interests'][$i];
}
$interests_final = implode(",",$interests);
echo sizeof($_POST['interests']);
Which is somewhat modified from what I originally wanted, but I guess it will still work. Still, I learned a great deal about checkboxes, and I appreciate all of your help! Thank you very much!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

if (isset($_POST['interests']) && $count = count($_POST['interests']))
{ 
   $interests_final = implode(',' $_POST['interests']);

   echo $count;
}
A little shorter version, no need for a loop.
Post Reply