php - Display saved checkbox value -
i have checkbox options save in db. able view , select multiple options , save them in db. issue want display saved information don't know how that.
<form action="save_comp.php" method="post"> <?php //display include ('mysql_connect.php'); $sql = mysql_query("select * competency "); //$row = mysql_fetch_array($sql); while($row = mysql_fetch_array($sql)) { echo"<input type='checkbox' name='comp[]' value= ".$row['id']." /> ".$row['competency']." <br />"; } ?> <input name="submit" type="submit" value="submit" /> </form>
save db
<?php session_start(); $id = $_session['user_id']; //$id = 3; include ('mysql_connect.php'); $insstr = ''; foreach($_post['comp'] $val){ $insstr .=$val.","; } mysql_query("insert competency_result (user_id,result) values ( '$id', '$insstr' )") or die(mysql_error()); echo'<script>alert("inserted successfully")</script>'; ?>
all want display saved information in table format. tried doing showed me saved id
<?php $res= mysql_query("select * competency_result user_id = '$user'")or die(mysql_error()); while($row = mysql_fetch_array($res)) { echo"<tr>"; echo"<td> $row[result]</td>"; ?> <?php echo"</tr>"; } ?>
<form action="save_comp.php" method="post"> <?php //display include ('mysql_connect.php'); $sql = mysql_query("select * competency "); //$row = mysql_fetch_array($sql); while($row = mysql_fetch_array($sql)) { echo"<input type='checkbox' name='comp[". $row['id']. "]' value='". $row['competency'] ."' /> ".$row['competency']." <br />"; } ?> <input name="submit" type="submit" value="submit" /> </form>
Comments
Post a Comment