close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Concatinate Check Boxs into one insert

Thread began 11/01/2010 8:06 am by nickj | Last modified 11/03/2010 6:46 am by Jason Byrnes | 1545 views | 5 replies |

nickj

Concatinate Check Boxs into one insert

Goal: Have a dynamic list to check boxes which will be inserted into one field in the DB coma separates!

For example; I have check boxes for red(1), green(2), blue(3) and yellow(4). I want the client to select as many as they wish and insert the numbers into one field in the DB. So the field colors might have a value of 1,3,4.

Any ideas

Nick

Sign in to reply to this post

Jason ByrnesWebAssist

the first key to this is to name your chechboxes the same name, and ending with "[]"


for example:
<inpout type="checkbox" name="color[]" value="red" />


Now in the insert record behavior, when you bind to the checkbox. the code will look like:

php:
<?php echo(isset($_POST['color'])?$_POST['color']:""); ?>





you will need to edit this to use the implode function to convert the array to a comma separated list:

php:
<?php echo(isset($_POST['color'])?implode(", "$_POST['color']):""); ?>
Sign in to reply to this post

nickj

I'm using this in an update. Becauce you had me change the and to include [] it was picked up as I added the update. Do I need to delete the []?

This is my before and after, do I have his right?

<?php echo ((isset($_POST["theme_img[]"]))?$_POST["theme_img[]"]:""); ?>

<?php echo ((isset($_POST["theme_img[]"]))?implode(",",$_POST["theme_img[]"]:"")); ?>

Thanks Nick

Sign in to reply to this post

nickj

Not update happening and no errors, the redirect works so the update thinks it's working but it's not.

There must be a problem with the update statement.

Attached Files
annotate.php.zip
Sign in to reply to this post

nickj

Got it to work on e one: <?php echo (isset($_POST['theme_img'])?implode(", ", $_POST['theme_img']):""); ?>

This is awesome! Opens doors..

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

yes, the brackets "[]" should only be included in the form element name, not in the echo statement


Think of it this way:
By adding the brackets at the end, you are creating an array.

the brackets are not needed when referencing the array though, they are only needed to create it.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...