jkkenzie Posted April 14, 2008 Share Posted April 14, 2008 <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 Quote Link to comment Share on other sites More sharing options...
bobinindia Posted April 14, 2008 Share Posted April 14, 2008 Where are you defining your variables? eg $strEmail; Coming from a database is more likely to be <?php echo $row['columnName']; ?> to show the value Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 14, 2008 Share Posted April 14, 2008 If you would like to have a checkbox checked when it loads, you need to set the attribute checked. For example: <input type="checkbox" value="Whatever" checked="checked" /> Quote Link to comment Share on other sites More sharing options...
haku Posted April 14, 2008 Share Posted April 14, 2008 note: This is an HTML question, not a php question, and should be in the html section of the forum. Quote Link to comment Share on other sites More sharing options...
jkkenzie Posted April 14, 2008 Author Share Posted April 14, 2008 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 Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 14, 2008 Share Posted April 14, 2008 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.' />' ?> Quote Link to comment Share on other sites More sharing options...
jkkenzie Posted April 15, 2008 Author Share Posted April 15, 2008 what are normally contained in a field that belongs to a checkbox item on a page? is it either 1 or 0 or there are other values in a tinyint field mysql?? Regards, Joseph Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.