我制作的代码在表的每一行之后显示标题。 我只希望标题出现在顶部一次,有什么帮助吗?
print "<table border=1>\n";
while ($row = mysql_fetch_array($result)){
$files_field= $row['filename'];
$files_show= "Uploads/$files_field";
$descriptionvalue= $row['title'];
print "<tr>";
print "<th>";
echo "header1";
print "</th>";
print "<th>";
echo "header2";
print "</th>";
print "</tr>";
print "<tr>\n";
print "\t<td>\n";
echo "<font face=arial size=4/>$descriptionvalue</font>";
print "</td>\n";
print "\t<td>\n";
echo "<div align=center><a href='".$files_show."' target='_blank' title='CLICK TO OPEN'>$files_field</a></div>";
print "</td>\n";
print "</tr>\n";
}
print "</table>\n";
答案 0 :(得分:1)
该程序将:
您想要的声音
答案 1 :(得分:0)
我认为这应该足够了
<?php
// print the beginning of the table, and the header
echo "<table border='1'>";
echo "<tr>";
echo "<th>";
echo "header1";
echo "</th>";
echo "<th>";
echo "header2";
echo "</th>";
echo "</tr>";
// than loop through the rows and print the rest of the table
while ($row = mysql_fetch_array($result)) {
$files_field = $row['filename'];
$files_show = "Uploads/{$files_field}";
$descriptionvalue = $row['title'];
echo "<tr>\n";
echo "\t<td>\n";
echo "<font face=arial size='4'/>$descriptionvalue</font>";
echo "</td>";
echo "<td>";
echo "<div align=center><a href='{$files_show}' target='_blank' title='CLICK TO OPEN'>{$files_field}</a></div>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
一些其他说明/建议:
print
/ echo
:它们几乎相同,只会引起混乱mysql
驱动程序,使用mysqli
:前者太过老了,它已从新版本的PHP(从7.0版)中删除,因此,如果平台已更新; mysqli
变体在使用方式上有所不同(通常是一个额外的参数),但是结果的格式相同,并且即使与旧变体的行为也非常相似,因此您将不必重写很多东西