[英]Display data in a PHP table MySQL using mysqli_fetch_array
At the moment, the data is shown in a line, where I need it in a tabular format. 目前,数据以一行显示,在这里我需要以表格格式显示。
There would be 5 headings which would align to the 5 'data types' below. 将有5个标题与以下5个“数据类型”对齐。
echo "<h3>search results for <i>". $keyword."</i></h3><br>";
while($result_arr = mysqli_fetch_array( $result ))
{
echo $result_arr['datatype1'];
echo $result_arr['2'];
echo $result_arr['3'];
echo $result_arr['4'];
echo $result_arr['5'];
}
$anymatches=mysqli_num_rows($result);
It's just a case of formatting the output as @Phil-Cooper says: 这只是将输出格式化为@ Phil-Cooper所说的一种情况:
echo "<h3>search results for <i>".$keyword."</i></h3><br><table><tr><th>Heading 1</th><th>Heading 2</th><th>Heading 3</th><th>Heading 4</th><th>Heading 5</th></tr>";
while($result_arr = mysqli_fetch_array( $result ))
{
echo "<tr><th>".$result_arr['datatype1']."</th>";
echo "<th>".$result_arr['2']."</th>";
echo "<th>".$result_arr['3']."</th>";
echo "<th>".$result_arr['4']."</th>";
echo "<th>".$result_arr['5']."</th></tr>";
}
echo "</table>";
$anymatches=mysqli_num_rows($result);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.