php - How to store multiple values against each records fetched from database and pass it to other page

748

I working with a web page which displays all the records of students [id, name, subject name, attendance status] that is displaypage.php

    $query="SELECT * FROM tbl_stu_rec WHERE Degree_name='".$degree."' ";
    $result=mysql_query($query);
    $num= mysql_num_rows($result);
    <?php
    $i=0;
    while ($i< $num)
    {
        $f1=mysql_result($result,$i,"Reg_no");
        $f2=mysql_result($result,$i,"First_name");
        $f3=mysql_result($result,$i,"Degree_name");
    <form action="adattendanDb.php" method="GET">       

                <tr align="center">
                    <td><?php echo $f1; ?> </td>
                    <td><?php echo $f2; ?> </td>
                    <td><?php echo $f3; ?> </td>
                                 <td><select id='attend' name='attendancestatus' >
                            <option>p</option>
                    <option>a</option>

                         </select>
                     </td>
                     </tr>                          
<?php
$my_array[$i]['id'] = $f1;
$my_array[$i]['fn'] = $f2;
$my_array[$i]['deg'] = $f3;
$i++;
}
?>
<input type="submit" value="Add Attendance">
</form>

Now i want to store the values (note there are multiple equal record against each value which is being fetched from db) in variable in a way that i will be able get them on next page where i can save all the record against their values in database including their attendance status ? in adattendanDb.php I need help with that thanks.

444

Answer

Solution:

    <form action="adattendanDb.php" method="GET">  
<?php
    $my_array = array();

    while ($row = mysql_fetch_array($result))
    {
        $f1 = $row["Reg_no"];
        $f2 = $row["First_name"];
        $f3 = $row["Degree_name"];

?>
        <tr align="center">
            <td><?php echo $f1; ?> </td>
            <td><?php echo $f2; ?> </td>
            <td><?php echo $f3; ?> </td>
            <td><select id='attend' name='attendancestatus' >
                <option>p</option>
                <option>a</option>
                </select>
            </td>
         </tr>   

<?php
        $my_array[]['id'] = $f1;
        $my_array[]['fn'] = $f2;
        $my_array[]['deg'] = $f3;
    }
?>

<input type="submit" value="Add Attendance">
</form>

People are also looking for solutions to the problem: jquery - PHP web page middle div content loading twice

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.