ianao Posted September 16, 2008 Share Posted September 16, 2008 Hi I want PHP to fetch the data from a mySQL table and display on each line a checkbox. The checkbox should be either ticked or unticked depending on whether the data reads true or false. Here is my code snippet: while($row= mysql_fetch_array($rs) ) { $list .= "<tr>"; $list .= "<td>".$row["id"]."</td>"; $list .= "<td>".$row["Author"]."</td>"; $list .= "<td>".$row["Page"]."</td>"; if($row["publish"]==1) { $publish="CHECKED"; } else { $publish=""; } $list .= "<td><input type=\"checkbox\" .$publish.></td>"; $list .= "</tr>"; } $list .= "</table>"; $list .= "</form>"; echo($list); The checkboxes that should be ticked do not display as ticked. Any suggstions would be very welcome indeed. Best Ianao Link to comment https://forums.phpfreaks.com/topic/124441-php-and-checkboxes/ Share on other sites More sharing options...
JasonLewis Posted September 16, 2008 Share Posted September 16, 2008 It should throw an error. Try this: $list .= "<td><input type=\"checkbox\" ".$publish."></td>"; And you should do it like this: $publish="checked='checked'"; Link to comment https://forums.phpfreaks.com/topic/124441-php-and-checkboxes/#findComment-642627 Share on other sites More sharing options...
ianao Posted September 16, 2008 Author Share Posted September 16, 2008 That's it! Fantastic! Thankyou so much for your help. Best Ianao Link to comment https://forums.phpfreaks.com/topic/124441-php-and-checkboxes/#findComment-642827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.