2015-02-09 91 views
0

我有一個彈出形式從用戶獲得數據並將其添加到MySQL的phpMyAdmin的表,我希望能夠以一個HTML表格一旦彈出關閉中顯示這個數據,在我點擊提交後,我被引導回主頁,在那裏我想讓數據顯示在桌面上。顯示MySQL數據與HTML表格

M.html

<thead>  
     <tr> 
      <th scope="col" colspan="2">CRN</th> 
      <th scope="col" colspan="6">Title</th> 
      <th scope="col" rowspan="2">Co-Ordinator</th> 
      <th scope="col" colspan="6">Coursework Number</th> 
      <th scope="col" rowspan="2">Contribution</th> 
      <th scope="col" colspan="6">Edit</th> 
      <th scope="col" rowspan="2">Upload</th> 
      <th scope="col" colspan="6">Manage Grades</th>   
     </tr> 

     </table> 

add.php

$display_query = "SELECT CRN, Title, Co-Ordinator, CourseworkNumber, Contribution FROM Modules"; 
$displayresult = mysqli_query($con, $display_query); 

$num = mysql_numrows($displayresult); 

mysqli_close($con); 

header("Location: ../views/M.html"); 

我新的HTML和PHP不確定如何鏈接這到HTML

+0

有啥問題只是選擇另一頁上的數據和顯示或發送JSON http://stackoverflow.com/a/19027741/3841803 – silentprogrammer 2015-02-09 19:14:14

回答

1

您不能執行PHP代碼中你可以這樣做多種方式。在牛市中,在中國的商店方法是這樣的:

<thead>  
    <tr> 
     <th scope="col" colspan="2">CRN</th> 
     <th scope="col" colspan="6">Title</th> 
     <th scope="col" rowspan="2">Co-Ordinator</th> 
     <th scope="col" colspan="6">Coursework Number</th> 
     <th scope="col" rowspan="2">Contribution</th> 
     <th scope="col" colspan="6">Edit</th> 
     <th scope="col" rowspan="2">Upload</th> 
     <th scope="col" colspan="6">Manage Grades</th>   
    </tr> 
<?php 
    $display_query = "SELECT CRN, Title, Co-Ordinator, CourseworkNumber, Contribution FROM Modules"; 
    $displayresult = mysqli_query($con, $display_query); 

    while($row = mysqli_fetch_assoc($display_query)) { // loop through the returned rows 
     // output each elemment 
     echo '<tr>'; 
     echo '<td>' . $row['CRN'] . '</td>'; 
     // other column items in the same fashion 
     echo '</tr>'; 
    } 

    mysqli_close($con); 

?> 
</table> 
+0

我是否將html代碼從M.html文件中取出並放入add.php中? – 2015-02-09 19:49:41

+0

你可以,或者你可以在M.html文件中加入add.php。 – 2015-02-09 20:19:13

+1

*「牛仔在中國店」* - 祝大家新年快樂;-) – 2015-02-11 20:25:44

0

上執行fetch查詢您的主頁。爲此,請從M.htmlM.php並執行查詢以從數據庫獲取數據。

<table> 
<th> <!--table headers--> </th> 
<?php 
$query = $con ->query(SELECT * FROM Modules); 
while($row = $query->fetch){ 
echo '<tr>'; 

echo '<td>'.$row['CRN'].'</td>'; 
echo '<td>'.$row['Title'].'</td>'; 
echo '<td>'.$row['Co-Ordinator'].'</td>'; 
echo '<td>'.$row['CourseworkNumber'].'</td>'; 
echo '<td>'.$row['Contribution'].'</td>'; 

echo '</tr>' 

} 
?> 
</table> 

PS - 在.html文件