make checkbox automatically checked within table PHP -
i new php , have problem. have table check boxes. need add together if statement within check box.
echo "<div class='table1'> <table> <tr> <td></td> <td>module code</td> <td>module title</td> <td>option</td> </tr>"; echo "<form action='confirmsubmission.php' method='post'>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . "<input type='checkbox' name='check[]' value='".$row['module_id']."' />" . "</td>"; echo "<td>" . $row['module_id'] . "</td>"; echo "<td>" . $row['module_title'] . "<a href=# content='".$row['description']."' class='tooltip'><span title='module description'><img src='images/i.png'/></span> </a>". "</td>"; echo "<td>" . $row['module_choice'] . "</td>"; echo "</tr>"; } echo "</table></div>";
below if statement need add together after value='".$row['module_id']."'
if($row['module_choice']=='mandatory'){ echo "checked=\"true\""; }
a bit of mouthful, try:
... echo "<td>" . "<input type='checkbox' name='check[]' value='".$row['module_id']."'".($row['module_choice']=='mandatory' ? 'checked="true"' : "")." />" . "</td>"; ...
php checkbox checked
No comments:
Post a Comment