Jump to content

checkbox problem


jkkenzie

Recommended Posts

<td width="120">Receipt Issued:</td><td><input name="ckReceiptIssued" type="checkbox" value="<?php echo $ckReceiptIssued; ?>"></td>
</tr>
<tr>
<td width="105">Receipt No.:</td><td><input name="strReceiptNo" type="text" value="<?php echo $strReceiptNo; ?>"></td>
<td width="115">Date Registered:</td><td><input name="dtDateRegistered" type="text" value="<?php echo $dtDateRegistered; ?>"></td>
<td width="100">D.O.B:</td><td><input name="dtDOB" type="text" value="<?php echo $dtDOB; ?>"></td>
</tr>
<tr>

<td width="100">E-mail:</td><td><input name="strEmail" type="text" value="<?php echo $strEmail; ?>"></td>
</form></table>

<table>
<tr><br>
<td align="left"><img src="images/below.JPG" align="left" width="60" height="60"></img></td>
</tr>
</table>
</body>
</html>

On my checkbox above (name="ckReceiptIssued"), am not able to display the value from my database, it should either have a tick or not. but my checkbox when i echo to form check box, it does not happen or does not show like other records display, what do i do??

 

Thanks

Joseph

Link to comment
https://forums.phpfreaks.com/topic/101011-checkbox-problem/
Share on other sites

this is a php question.

 

i have already declared the variables:

<?php $fieldvalue= $row['columnName'] ; ?>,

 

what do you mean i just :

<input type="checkbox" value="Whatever" checked="checked" />

 

i need to find from database if i have to check before i could do that.... i just cant check that is why i was saying my echoing does not work, how do i check the checkbox basing on the database value of the field "ckReceiptIssued" (tinyint(11))

 

thanks

 

Link to comment
https://forums.phpfreaks.com/topic/101011-checkbox-problem/#findComment-516605
Share on other sites

That depends on what the field is supposed to contain. If, for example, it was supposed to contain 1 for items that should be checked, and 0 for items which weren't you could do:

 

<?php
if($row['ckReceiptIssued'] == 1){
$selected = 'selected="selected"';
}else{
$selected = '';
}
echo '<input name="ckReceiptIssued" type="checkbox" '.$selected.' />'
?>

Link to comment
https://forums.phpfreaks.com/topic/101011-checkbox-problem/#findComment-516763
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.