2017-08-17 78 views
0

Html内容位于单独的文件中。然后我将这些文件包含在php文件中。数据以表格形式显示,但不是系统地显示?

这里问题是数据不是来自它们各自的标题,即 EmployeeID,EmployeeName,MobileNumber出现在“Mobilenumber”标题下。

头文件:

<div class="row" style="height:370px; width:850px; overflow:scroll;"> 
<table border ='1' align = "center" id="FormTable" class="table" > 
    <tr> 
     <th> Employee Code 
     <th> Employee Name 
     <th> Mobile Number 
    <tr> 
     <td> 
     <td> 
     <td> 

页脚文件:

</th> 
</th> 
</th> 
</tr> 
</td> 
</td> 
</td> 
</tr> 
</table> 
</div> 

主文件:

public function showEmployeeProfile() { 
     if (!isset($_SESSION["email"]) || !isset($_SESSION["passwrd"])) { 
      header("Location:index.php"); 
      // Cannot Access this page without Login. 
     } 
     if (empty($_POST)) { 
      if (isset($_SESSION['email'])) { 
       echo '<h3>' . "Welcome &nbsp '{$_SESSION['email']}'" . '</h3>'; 
       // Prints Email ID of the HR Manager. 
      } 

     echo '<h4>'.'<center>'."Profile Info of the Employees".'</center>'.'</h4>'.'<br/>'; 
     $read_sql = "select * from employeeprofile"; 
     $result_fetch = mysqli_query($this->connection, $read_sql); 
     include ("Header.php"); 
     while ($resultArr = $result_fetch->fetch_array()) { 
      echo $resultArr['EmployeeId'] . '<br/>'; 
      echo $resultArr['EmployeeName'] . '<br/>'; 
      echo $resultArr['MobileNumber'] . '<br/>' . '<hr/>'; 
     } 
     include ("Footer.php"); 
    } 
} 

我认为需要在页眉和页脚文件中进行更改。

+0

你是不是呼应数据插入到表行中​​元素!所以它不会正确显示在表格中 – RiggsFolly

回答

2

您需要对所有三个文件进行更正。

在您的标题:

<tr> 
    <th>Employee Code</th> 
    <th>Employee Name</th> 
    <th>Mobile Number</th> 
</tr> 

在您的页脚,</table>之前删除一切。

在你while()循环:

echo '<tr>'; 
echo '<td>' . $resultArr['EmployeeId'] . '</td>'; 
echo '<td>' . $resultArr['EmployeeName'] . '</td>'; 
echo '<td>' . $resultArr['MobileNumber'] . '</td>'; 
echo '</tr>';