我想要得到:
引言:
引用1
引用来源1
引用2
引用来源2
我目前得到:
引言:
引用1
引用来源1
引言:
引用2
引用来源2
对我有用的最终代码:
echo ("<table border='1'>");
$header_printed = false;
while($row = mysql_fetch_array($rs)) {
if ($row['quote']) {
if ($header_printed === false) {
echo "
<tr>
<th>Quotes:</th>
</tr>";
$header_printed = true;
}
echo "
<tr>
<td>".$row['quote']."</td>
<td>".$row['quote_source']."</td>
</tr>";
}
}
echo ("</table>");
最佳答案
echo "<table border='1'><tr><th>Quotes:</th></tr>";
while($row = mysql_fetch_array($rs)) {
if ($row['quote']) {
echo "<tr><td>".$row['quote']."</td><td>".$row['quote_source']."</td></tr>";
}
}
echo "</table>";
关于php - 如果字段不为空,如何显示带有标题的表格一次,后跟多个数据库字段内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15456389/