Jump to content

CHECKBOX in php.. HELP PLS.


jushiro

Recommended Posts

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. :D

Link to comment
https://forums.phpfreaks.com/topic/247419-checkbox-in-php-help-pls/
Share on other sites

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>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.