0

i have a dynamic table whose values came from the database. the user will select records from the table then save the result to another table. i have the following code:


<?php
echo "<form method='post' action='save_result.php'>";
$subjects="table1";

$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" .
realpath("data.mdb").";";
$conn=odbc_connect($connstr,'','')
or die("connect error: ".odbc_error());

$quey1="select * from $subjects";
$stmt=odbc_prepare($conn, $quey1) or die (Print "odbc prepare error".odbc_error());
$result=odbc_exec($conn,$quey1)
or die ("result error ".odbc_error().'-'.odbc_errormsg());
?>
<table border=1 style="background-color:#F0F8FF;" >
<caption><EM>Student Record</EM></caption>
<tr>
<th>Choose Subject</th>
<th>Subject Code</th>
<th>Description</th>
<th>Units</th>
</tr>
<?php
while($row=odbc_fetch_array($result)){

echo "</td><td>";
echo "<input type='checkbox' name='check[]'>";
echo "</td><td>
echo $row;
echo "</td><td>";
echo $row;
echo "</td><td>";
echo $row;
echo "</td></tr>";
}
?>
</table>
<input type="submit" value="next" name="next">
</form>

the code is working my problem is how to save the values to another table in the database after the user selects the subjects using the check boxes. can somebody help me!

2
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by karthik_ppts
0

assign stud_no value to the check box as follows

echo "<input type='checkbox' name='check[]' value='".$row['stud_no']."'>";

and store this value in another table while submit.

Use [code] tags to post your codes

Edited by Dani: Fixed formatting

0

assign stud_no value to the check box as follows
echo "<input type='checkbox' name='check[]' value='".$row['stud_no']."'>";

and store this value in another table while submit.

Use code-tags to post your codes

Thanks, Can you pls write the exact code for each.
Im still a student. Thanks

Edited by mike_2000_17: Fixed formatting

0

assign stud_no value to the check box as follows
echo "<input type='checkbox' name='check[]' value='".$row['stud_no']."'>";

and store this value in another table while submit.

Use code-tags to post your codes

i've tried it but it writes the word array in my table fields.

Edited by mike_2000_17: Fixed formatting

0

i've tried it but it writes the word array in my table fields.

post your code here with CODE tags

Edited by happygeek: fixed formatting

0

post your code here with code-tags

Thank You! It works. Your great!

Edited by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.