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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.