如何针对从数据库中提取的每个记录存储多个值,并将其传递给其他页面

时间:2014-01-25 12:08:30

标签: php mysql

我使用的网页显示学生的所有记录[身份证,姓名,科目名称,出勤状况],即di​​splaypage.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>

现在我想在变量中存储值(注意对于从db中获取的每个值有多个相等的记录),我将能够在下一页上获取它们,在那里我可以保存所有记录他们在数据库中的价值包括他们的出勤状况?在adattendanDb.php 我需要帮助,谢谢。

1 个答案:

答案 0 :(得分:0)

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