Hi, im a begineer of PHP. I tried create a library online shoping cart. i get $id value from DB... <input type="checkbox" name="Bookname[]" value="<?PHP echo $id ;?>"><?PHP echo $id ;?>..This is dynamic checkbox, which means i have three rows in table automatically display three checkbox one by one... what my doubt is.. i want to check this checkbox is checked means i want to do some action.. but i tried.. still im not getting any idea... please tel me which is good one.. Thanks.
You need to check whether the database value for that field name is set to the value you have set it to as checked. Example: <?php function checkbox_checked($value,$compare) { if($value == $compare) { echo ' checked'; } } ?> PHP: <input type="checkbox" name="field_name_here" value="value_here"<?php echo checkbox_checked('value_here',$db_value_for_field_here); ?> /> HTML: