jwk811 Posted February 9, 2007 Share Posted February 9, 2007 i have several checkboxes and i get it by doing foreach($check as $c){ echo $c . ', ';} but how can i make that entire thing put into one variable? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 are you looking for http://php.net/implode or http://php.net/explode ? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 9, 2007 Share Posted February 9, 2007 Do you want all the values from the $check array to be in a comma separated list as the value of a variable? If so, do it this way: <?php $csv_var = implode(',',$check); ?> Ken Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 9, 2007 Author Share Posted February 9, 2007 no i already figured that out now i need to get that data which will have all of the checked areas separated by commas, i need that to go into my db as a text or varchar.. do you know what i mean? Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted February 9, 2007 Share Posted February 9, 2007 use insert query to update your database: $sql = mysql_query("INSERT INTO table_name SET text = '$check'"); Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 9, 2007 Author Share Posted February 9, 2007 yeah but check only has the last option they picked.. im usually the foreach function to get them all but dont know how to put it into my database like that.. understand? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 If you already know how to implode the checkboxes into one variable, what don't you get? $check = implode(',', $check); $sql = mysql_query("INSERT INTO table_name SET text = '$check'"); Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted February 9, 2007 Share Posted February 9, 2007 if you dont understand our examples i think you should read more about the implode function. what jesirose wrote should do the trick, ohterwise you aint explaning your request good enough... Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 9, 2007 Author Share Posted February 9, 2007 oh implode will take all the checkboxes that were used? oh i see now.. i thought that the implode thing was only for the commas.. thanks ill look into that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.