如何在PHP中显示表中的数据
我在用PHP显示表时遇到问题。我已经安装了shortcode exec php插件 这是我所做的代码:如何在PHP中显示表中的数据,php,html,mysql,tabular,Php,Html,Mysql,Tabular,我在用PHP显示表时遇到问题。我已经安装了shortcode exec php插件 这是我所做的代码: if(mysql_num_rows($raw_results) > 0){ while($results = mysql_fetch_array($raw_results)){ echo "<p><h3>".$results['id']."</h3>"."Student Name :".$r
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>";
}
}
if(mysql\u num\u行($raw\u结果)>0){
而($results=mysql\u fetch\u数组($raw\u results)){
回显“”$results['id']”。“学生姓名:“$results['Name']”。”“”;
回显“年龄:.$results['Age'].“岁。”;
echo“课程:.$results['Course']。””;
回显“性别:.$results['Gender']。””;
回声“
”;
}
}
我可以知道如何在表格中整理数据吗?我尝试的任何表代码似乎都不会显示
<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中的数组排序
只需像这样回显html表格标记:
echo "<table border='1'>
<tr>
<th>Id</th>
<th>Age</th>
<th>Course</th>
<th>Gender</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['course'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo”
身份证件
年龄
课程
性别
";
while($row=mysqli\u fetch\u数组($result))
{
回声“;
回显“$row['id']”;
回显“$row['name']”;
回显“$row['course']”;
回显“$row['age']”;
回声“;
}
回声“;
身份证件
学名
年龄
课程
性别
而($results=mysql\u fetch\u数组($raw\u results)){
回声“;
回显“$results['id']”;
回显“$results['name']”;
echo“$results['age']”岁;
回显“$results['course']”;
回显“$results['gender']”;
回声“;
}
回声“;
您需要连接数据库,然后将数据提取到数据库
while($results = mysql_fetch_array($row)){
echo "<tr>";
echo "<td>".$results['id']."</td>";
echo "<td>".$results['name']."</td>";
echo "<td>".$results['age'].".</td>";
echo "<td>".$results['course']."</td>";
echo "<td>".$results['gender']."</td>";
echo "</tr>";
while($results=mysql\u fetch\u数组($row)){
回声“;
回显“$results['id']”;
回显“$results['name']”;
回显“$results['age']”;
回显“$results['course']”;
回显“$results['gender']”;
回声“;
您是否尝试在SQL查询中进行排序?我使用了此选项,但使用了mysql_fetch_数组($raw_results)){。还有其他方法吗?或者我必须使用mysql_fetch_数组($result))?
while($results = mysql_fetch_array($row)){
echo "<tr>";
echo "<td>".$results['id']."</td>";
echo "<td>".$results['name']."</td>";
echo "<td>".$results['age'].".</td>";
echo "<td>".$results['course']."</td>";
echo "<td>".$results['gender']."</td>";
echo "</tr>";