繁体   English   中英

如何从html表中选择行并获取第一个单元格的值并将其放在PHP Session上

[英]How select row from html table and get the value of the first cell and put it on PHP Session

我想选择并获取所选行的值或获取该行第一个单元格的值并在 PHP Session 上恢复它,但我不知道该怎么做。

       <?php

       include('dbconnection.php');


                echo "<table id='tblMain' width='100%' height='10%' border='2' align='center'>
                <tr width='100%' height ='10%'>
                <th>Applicant ID</th>
                <th>Lastname</th>
                <th>Firstname</th>
                <th>Middlename</th>
                <th>Age</th>
                <th>Gender</th>
                <th>Civil Status</th>
                <th>Cellphone</th>
                <th>Email Address</th>

                </tr>";

        $result= mysql_query("SELECT * FROM tbl_applicant");

while($row = mysql_fetch_array($result)){//this will fecth the values from database
                echo '<tr>';
                echo '<td>';
                echo $row['ApplicantID'];
                echo '</td>';
                echo '<td>';
                echo $row['Lastname'];
                echo '</td>';
                echo '<td>';
                echo $row['Firstname'];
                echo '</td>';
                echo '<td>';
                echo $row['Middlename'];
                echo '</td>';
                echo '<td>';
                echo $row['Age'];
                echo '</td>';
                echo '<td>';
                echo $row['Gender'];
                echo '</td>';
                echo '<td>';
                echo $row['CivilStatus'];
                echo '</td>';
                echo '<td>';
                echo $row['Cellphone'];
                echo '</td>';
                echo '<td>';
                echo $row['EmailAddress'];
                echo '</td>';

                    }
                echo '</tr>';
                echo '</table>'; 

                ?>

这是我的论文。

你必须开始会话,并设置 $_SESSION['key']=$value_you_want_to_store

       include('dbconnection.php');


                echo "<table id='tblMain' width='100%' height='10%' border='2' align='center'>
                <tr width='100%' height ='10%'>
                <th>Applicant ID</th>
                <th>Lastname</th>
                <th>Firstname</th>
                <th>Middlename</th>
                <th>Age</th>
                <th>Gender</th>
                <th>Civil Status</th>
                <th>Cellphone</th>
                <th>Email Address</th>

                </tr>";

        $result= mysql_query("SELECT * FROM tbl_applicant");

while($row = mysql_fetch_array($result)){//this will fecth the values from database
               ?><tr>
                    <td><?php echo $row['ApplicantID'];?></td>
                    <td><?php echo $row['Lastname'];?></td>
                    <td><?php echo $row['Firstname'];?></td>
                    <td><?php echo $row['Middlename'];?></td>
                    <td><?php echo $row['Age'];?></td>
                    <td><?php echo $row['Gender'];?></td>
                    <td><?php echo $row['CivilStatus'];?></td>
                    <td><?php echo $row['Cellphone'];?></td>
                    <td><?php echo $row['EmailAddress'];?></td>
             </tr><?php


             $_SESSION['ApplicantID']=$row['ApplicantID'];
             $_SESSION['Lastname']=$row['Lastname'];
             $_SESSION['Firstname']=$row['Firstname'];
             $_SESSION['Middlename']=$row['Middlename'];
             $_SESSION['Age']=$row['Age'];
             $_SESSION['Gender']=$row['Gender'];
             $_SESSION['CivilStatus']=$row['CivilStatus'];
             $_SESSION['Cellphone']=$row['Cellphone'];
             $_SESSION['EmailAddress']=$row['EmailAddress'];


             }


            ?> </table>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM