作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 PHP 中显示表格时遇到问题。我已经安装了短代码 exec php 插件。
这是我完成的代码:
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "<p><h3>".$results['id']."</h3>"."Student Name :".$results['name']." </p>" . "</br>";
echo "Age : ".$results['age']." Years old.</br>";
echo "Course : ".$results['course']."</br>";
echo "Gender : ".$results['gender']."</br></br>";
echo "<HR>";
}
}
我可以知道如何对表格中的数据进行排序吗?我尝试的任何表格代码似乎根本不显示..
最佳答案
<table>
<tr>
<td>Student name</td>
<td>Age</td>
<td>Course</td>
<td>Gender</td>
</tr>
<?php
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "<tr><td>".$results['id']."</td>";
echo "<td>".$results['age']."</td>";
echo "<td>".$results['course']."</td>";
echo "<td>".$results['gender']."</td></tr>";
}
}
?>
</table>
关于php - 如何在PHP中显示表格中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21772119/
我是一名优秀的程序员,十分优秀!