jushiro Posted September 19, 2011 Share Posted September 19, 2011 I'm having a problem on how to get the values of those that are checked in my table.. so that i can insert them in my database. Someone help get those values pls. Heres my code <?php $host="localhost"; $username="root"; $password=""; $db_name="dbprof"; $tbl_name="teacher"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); echo '<form name="formupload" method="post" action="val3.php">'; echo "<table border=\"5\" >"; echo "<tr><th>List of Instructor</th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "<input type='checkbox' name='list' 'value='" .$row['fullname']. "'> " .$row['fullname']. "<br/></td>"; echo "</tr>"; } } else { echo "<tr><td>No one to Approve</td></tr>"; } echo '<input type="image" src="images/reject.png" name="test" width="170" height="35" border="0" value="reject">'; echo '</form>'; ?> I dont know what to put in my val3.php' so that it can the values of the Checked data. Thx for those who can help. Quote Link to comment https://forums.phpfreaks.com/topic/247419-checkbox-in-php-help-pls/ Share on other sites More sharing options...
voip03 Posted September 19, 2011 Share Posted September 19, 2011 You can use this example to write your code <?php foreach ($_REQUEST['chkboxarray'] as $checkbox) { echo $checkbox; echo "<br/>"; } ?> <form action="val3.php" method="post"> <input type="checkbox" name="chkboxarray[]" value=1><br/> <input type="checkbox" name="chkboxarray[]" value=2><br/> <input type="checkbox" name="chkboxarray[]" value=3><br/> <input type="submit" name="submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/247419-checkbox-in-php-help-pls/#findComment-1270596 Share on other sites More sharing options...
jushiro Posted September 19, 2011 Author Share Posted September 19, 2011 I see it works. but, i dont use a submit button.. im using like a image button to direct it to other page. w/c is val3.php. val3 now will provide the process for getting the values.. What should i use instead of submit button? or what should i write on val3.php? should i use isset? Quote Link to comment https://forums.phpfreaks.com/topic/247419-checkbox-in-php-help-pls/#findComment-1270598 Share on other sites More sharing options...
jushiro Posted September 19, 2011 Author Share Posted September 19, 2011 yay! my bad.. your code works! thx! Quote Link to comment https://forums.phpfreaks.com/topic/247419-checkbox-in-php-help-pls/#findComment-1270601 Share on other sites More sharing options...
voip03 Posted September 19, 2011 Share Posted September 19, 2011 <input type="image" name="submit" src="image/submit.JPG" height="20" width="50" border="0" alt="Submit Form" /> No more question to ask, please make it solved. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/247419-checkbox-in-php-help-pls/#findComment-1270602 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.