0

Right now i changed from options table to my own table so things are getting difficult

i have a checkbox its name is selection in table, so here is what i tried

<input type="checkbox" name="selection" value="1"<?php checked("1",$item['selection']);?> />
<input type="checkbox" name="selection" value="2"<?php checked("2",$item['selection']);?> />
<input type="checkbox" name="selection" value="3"<?php checked("3",$item['selection']);?> />

This is not saving any value , Then i tried as array in below

<input type="checkbox" name="selection[]" value="1"<?php checked("1",$item['selection']);?> />
<input type="checkbox" name="selection[]" value="2"<?php checked("2",$item['selection']);?> />
<input type="checkbox" name="selection[]" value="3"<?php checked("3",$item['selection']);?> />

It is throwing warning Warning: mysql_real_escape_string() expects parameter 1 to be string, array given

How to store multiple values with the same name in checkbox when using my own table?

Any help help would be greatful.

2
  • This is not saving any value you mean you are not getting values checked ? Commented Oct 31, 2013 at 10:03
  • Yep exactly,the checkbox is not checked @wordpresser Commented Oct 31, 2013 at 10:04

1 Answer 1

1

i suppose checked is a function and you are returning vaule with it. if thats true than you are missing an echo before your checked function

<?php echo checked("1",$item['selection']);?>

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer +1. But this is not working.the check box is not checked.i have only one field that is selection, so is that possible to store multiple values in this one field
When i check a multiple selection it is selecting only one which is recently selected. If there is four checkbox selected it is selecting only one out of four
In what way can i show? I don't know to show it.could you explain a bit to show it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.