Copy link to clipboard
Copied
Using DW 5.5
Imported an MS Access DB table into MySQL table. Access table had Y/N (checkbox) fields; import to MySQL resulted in those fields labeled as TinyInt(1). All of these fields contain either a 0 or 1.
Created (Edit) form with controls to display each of the fields however when a table record is displayed none of those controls show a checkmark (other fields in the records display properly). I've checked many records just to ensure I'm picking at least one with both values across the number of fields in the record.
Is 'TinyInt(1)' the proper type field in the table to hold a checkbox value?
And if not, to what type should the field be changed?
If a change of field type for these fields is necessary, will I lose the current contents? (too many to chance a loss - and yes, I could back up the table just in case)
My query is SELECT * from ..... (so I know I should be acquiring all the fields in the records)
and the display code is (checkboxes do appear but with nothing in them)
<td><input name="M_695" type="checkbox" id="M_695" value="<?php echo $row_getMembers['M_695']; ?>" /></td>
<td><input name="M_696" type="checkbox" id="M_696" value="<?php echo $row_getMembers['M_696']; ?>" /></td>
<td><input name="M_1_112" type="checkbox" id="M_1_112" value="<?php echo $row_getMembers['M_1_112']; ?>" /></td>
<td><input name="M_2_112" type="checkbox" id="M_2_112" value="<?php echo $row_getMembers['M_2_112']; ?>" /></td>
<td><input name="M_3_112" type="checkbox" id="M_3_112" value="<?php echo $row_getMembers['M_3_112']; ?>" /></td>
<td><input name="M_4_112" type="checkbox" id="M_4_112" value="<?php echo $row_getMembers['M_4_112']; ?>" /></td>
<td><input name="M_5_112" type="checkbox" id="M_5_112" value="<?php echo $row_getMembers['M_5_112']; ?>" /></td>
<td><input name="M_6_112" type="checkbox" id="M_6_112" value="<?php echo $row_getMembers['M_6_112']; ?>" /></td>
<td><input name="M_7_112" type="checkbox" id="M_7_112" value="<?php echo $row_getMembers['M_7_112']; ?>" /></td>
Thanks in advance,
Tom
Copy link to clipboard
Copied
Hi Tom,
Is 'TinyInt(1)' the proper type field in the table to hold a checkbox value?
Yes, it is OK.
and the display code is (checkboxes do appear but with nothing in them)
<td><input name="M_695" type="checkbox" id="M_695" value="<?php echo $row_getMembers['M_695']; ?>" /></td>
<td><input name="M_696" type="checkbox" id="M_696" value="<?php echo $row_getMembers['M_696']; ?>" /></td>
<td><input name="M_1_112" type="checkbox" id="M_1_112" value="<?php echo $row_getMembers['M_1_112']; ?>" /></td>
<td><input name="M_2_112" type="checkbox" id="M_2_112" value="<?php echo $row_getMembers['M_2_112']; ?>" /></td>
<td><input name="M_3_112" type="checkbox" id="M_3_112" value="<?php echo $row_getMembers['M_3_112']; ?>" /></td>
<td><input name="M_4_112" type="checkbox" id="M_4_112" value="<?php echo $row_getMembers['M_4_112']; ?>" /></td>
<td><input name="M_5_112" type="checkbox" id="M_5_112" value="<?php echo $row_getMembers['M_5_112']; ?>" /></td>
<td><input name="M_6_112" type="checkbox" id="M_6_112" value="<?php echo $row_getMembers['M_6_112']; ?>" /></td>
<td><input name="M_7_112" type="checkbox" id="M_7_112" value="<?php echo $row_getMembers['M_7_112']; ?>" /></td>
Code should be:
<input name="M_695" type="checkbox" id="M_695" value="1" <?php if (!(strcmp(htmlentities($row_getMembers['M_695'], ENT_COMPAT, 'utf-8'),1))) {echo "checked=\"checked\"";} ?> /> (Dreamweaver's code style).
It is not the value that makes the checkbox checked, that is the attribute "checked=\"checked\"" (XHTML) or simply "checked" (HTML).
Dreamweaver can help you write the good code (at least, up to CS6, I do not know for DW CC): click the Dynamic button in the property inspector of a checkbox.
Regards,
Xavier
Copy link to clipboard
Copied
Thanks very much. Cripes, I looked all over for this. Probably missed the 'how to/whats this' item that said 'click the Dynamic Button'!
Tom