Waddy Posted October 20, 2010 Share Posted October 20, 2010 I have a number of fields to display on a page, from a mysql query, some fields are empty, some not. depends on what they choose on the original form. I am trying to display on the form results on a page formatted using the below: If the mysql field is empty, display an unchecked check box next to the result. If there is data in the field display a check box ticked. What can i do to achieve this, can you point me in the right direction? Results page using echo: </TD><TD>Options: <input type='checkbox' CHECKED>". $row[17]. " </TD> = is not empty field </TD><TD>Options: <input type='checkbox' UNCHECKED>". $row[17]. " </TD> = emtpy ,mysql field </TD><TD>Options: <input type='checkbox' CHECKED>". $row[18]. " </TD> = not empty mysql field from query </TD><TD>Options: <input type='checkbox' UNCHECKED>". $row[18]. " </TD> = Empty field in mysql I am trying to show Rows 1 to 16 to display normally, rows 17 to 30 use the above logic. There are about 30 fields to display like this, the others are required fields and are displayed no matter what. Link to comment https://forums.phpfreaks.com/topic/216316-if-field-is-empty/ Share on other sites More sharing options...
Waddy Posted October 20, 2010 Author Share Posted October 20, 2010 Solved by Judda in IRC, thanks! Provided Example: <input type = 'checkbox' <?php if ( ! empty ( $row [ 'field' ] ) ) echo 'checked = \'checked\'';?></input> Link to comment https://forums.phpfreaks.com/topic/216316-if-field-is-empty/#findComment-1124179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.