0

I'm trying to submit data with check box selection. I want to carry all selected check box values to next page where i can insert that to database.

But i am not getting how to carry text box values.

Here is my form

else if($status=='unpaid')
    {
    echo "<form method='post' action='update_fee.php' name='fee'>"; 
        echo "<table id='staff_form'>

<tr bgcolor='#ffffff'>
<td>Fee Type</td>
<td>LAST DATE</td>
<td>AMOUNT</td>
<td>LATE FINE</td>
<td>ENROLL NO</td>
<td>STUDENT NAME</td>
<td>Pay Amount</td>
<td>Late Fine</td>
<td></td>
<td></td></tr>
";

$count=mysql_num_rows($query);
if($count==0)
{
echo "<tr><td colspan='7'>SORRY NONE OF THE RECORD FOUND IN TABLE</td></tr>";
}
else
{

while($row=mysql_fetch_array($query))
{

?>

<tr bgcolor="<?php echo $bgcolor; ?>"><td id="staff_reg_no"> <input type="text" value="<?php echo $row['type']; ?>" name="type"></td>
<td id="staff_reg_no"><?php echo $row['last_date']; ?></td>
<td id="staff_reg_no"><?php echo $row['fee_amount']; ?></td>
<td id="staff_reg_no"><?php echo $row['late_fine']; ?></td>
<td id="staff_reg_no"><a href="update_fee.php?enroll_no=<?php echo $row['enroll_no']; ?>"><?php echo $row['enroll_no']; ?></a></td>
<td><?php echo $row['stud_name']; ?></td>
<td><input type="text" name="amount"></td>
<td><input type="text" name="latefee"></td>
<td><input type="checkbox" name="sel[]" value="<?php echo $row['enroll_no']; ?>, <?php echo $row['fee_amount']; ?>, <?php echo $row['stud_name']; ?>"></td>
<input type="hidden" name="enroll_no" value="<?php echo $row['enroll_no']; ?>">

<td></td>
</tr>

<?php

}
echo '<tr><td><input type="submit" value="Update" name="update">

</form></table>';
}


    }

update_fee.php

   if(isset($_POST['update']))
{
//echo "hello";
$type = $_POST['type'];
$amount = $_POST['amount'];
$enroll_no = $_POST['enroll_no'];
$latefee = $_POST['latefee'];

echo $type;
echo $amount;
echo $enroll_no;

$opt[] = $_POST['sel'];

foreach($_POST['sel'] as $enroll_no)
{
    echo 'Checked: '.$enroll_no.'
';
}

but i am not getting why it is not taking $_POST['latefee'] and $_POST['amount'] or how i can pass it from the previous page with checkbox selection , after entering payment amount.

user3368088
  • 151
  • 2
  • 15
  • You need to change the name of input boxes. http://stackoverflow.com/questions/7880619/multiple-inputs-with-same-name-through-post-in-php – Vicky Apr 17 '14 at 11:41

1 Answers1

0
//$opt = $_POST['sel'];

foreach($opt  as $values)
{
   if($values == $match)
   {
    $chk = 'checked="checked"';
   }
   else
  {
    $chk = '';
   }
echo '<input type="checkbox" '.$chk.' name="sel[]" value='.$var.'>';
}
Neeraj
  • 197
  • 7
  • i am not able to relate it to my code :(. I tried the same. what i should put in the place of $match? I tried but it gave me single value with a checkbox – user3368088 Apr 17 '14 at 11:47