Editing Checkbox

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

Post Reply
User avatar
burnhallian
Forum Commoner
Posts: 28
Joined: Tue Jul 12, 2005 2:47 am

Editing Checkbox

Post by burnhallian »

Hi All !

Im editing a php page and i have to retrive the value of a checkbox and im not sure how to get that :cry:
The part of the code is below. Kindly tell me how to get back the value of check box and display it on the page, this code displays the checkbox as checked always irrespective of whether it was selected or not.

Code: Select all

tr><td>
<input type="checkbox" name="dis6" value="1"<?php if(isset($row['dis6'])) echo 'checked';?>>

<font face="Arial" size="3">Integration & Customization </td></tr>
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Code: Select all

<input type="checkbox" name="dis6" value="<?php echo $_POST['dis6'] . '"'; if(isset($row['dis6'])) echo 'checked'; ?>>
Edit: You should also change checked into checked="checked" if you want the code to be valid XHTML.
Post Reply