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!

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

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

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.

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

post your code here with CODE tags

post your code here with code-tags

Thank You! It works. Your great!

Mark this thread as solved if your problem solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.