0

这里的问题是我需要在单击按钮时在查看详细信息页面中查看整行数据但是当我单击最后一行数据时通过会话变量发送并显示最后一行但我需要特定行在名称时完全显示被选中的员工。请帮帮我。

谢谢你

索引.php

<?php
include('connection.php');
$sql = "SELECT empname,salary,contact_no,department,empdesg FROM add_emp ORDER BY empname ASC ";
$result = $con->query($sql);
if ($result->num_rows > 0)
                {
                // output data of each row
                ?>
                <center>
<table cellpadding="20px" cellspacing="40px;" border="2px" align="center" width="device">
<tr>
<th>Name</th>
                            <th>Department</th>
                            <th>Designation</th>
                            <th> </th>
                            <?php
                            while($row = $result->fetch_assoc())

                            {
                            $name='';
                            $name=$row["empname"];
                            $department=$row["department"];
                            $designation=$row["empdesg"];
                            ?>
 </tr>
<td>
<?php echo $name?>
</td>

                        <td>
                            <?php echo $department?>
                        </td>
                        <td>
                            <?php echo $designation?>
                        </td>


                        <td><a href="viewdetails.php">
                            <button>Details</button>
                            </a>
                            <?php

                            $_SESSION['name']= $name;
                            ?>

                        </td>
                        <?php
                        }
                        } 
                        else {
                        echo "0 results";
                        }

                        ?>

查看详情.php

    <?php
session_start();
include('connection.php');

$sql="select * from add_emp where empname='$_SESSION[name]'";
$result = mysqli_query($con, $sql); // First parameter is just return of "mysqli_connect()" function
echo "<br>";
echo " <table cellpadding='5px' cellspacing='10px' border='1px' align='center'>";
while ($row = mysqli_fetch_assoc($result)) 
{ // Important line !!! Check summary get row on array ..
    echo "<tr>";
    echo "<th>" ."Name". "</th>";
    echo "<td>" .$row['empname']. "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<th>" ."DOB". "</th>";
    echo "<td>" .$row['eage']. "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<th>" ."Adhaar Number". "</th>";
    echo "<td>" .$row['adhaar']. "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<th>" ."Address". "</th>";
    echo "<td>" .$row['address']. "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<th>" ."Salary". "</th>";
    echo "<td>" .$row['salary']. "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<th>" ."Phone Number". "</th>";
    echo "<td>" .$row['contact_no']. "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<th>" ."Department". "</th>";
    echo "<td>" .$row['department']. "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<th>" ."Designation". "</th>";
    echo "<td>" .$row['empdesg']. "</td>";
         echo "</tr>";
             echo "<tr>";
}
echo "</table>";
?>
4

0 回答 0