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
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>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.