以下代码未按预期运行。我想要3列,第一列是站点名称,第二列是类别,第三列是RSS的URL(还没有到达那个部分)。数据在数据库中,但是当我查看下面语句的结果时,站点名称结果链接到我所在的当前网页。我非常感谢帮助您正确地在页面上显示每列数据。谢谢
<?php
$query="SELECT * FROM SOMETABLE";
$result=mysql_query($query);
$num = mysql_numrows($result);
echo "
<table border='1'>
<th>Site Name:</th>
<th>Category:</th>
<th>RSS:</th>";
$i=0;
while ($i < $num) {
$siteName =mysql_result($result,$i,"siteName");
$category =mysql_result($result,$i,"category");
$category =mysql_result($result,$i,"url");
$rss =mysql_result($result,$i,"rss");
echo "
<tr>
<td><a href='$url'>$siteName</a></td>
<td>$category</td>
<td>$rss</td>
</tr>";
$i++;
}
?>
答案 0 :(得分:2)
echo "<table>"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr>"; echo "<td>$line ["siteName"]</td>"; echo "<td>$line ["category"]</td>"; echo "<td>$line ["url"]</td>"; echo "<td>$line ["rss"]</td>"; echo "</tr>"; } echo "</table>";
跳过$ num,mysql_resuls(你怎么做)在标题中打开行TR(我跳过它)并关闭表
答案 1 :(得分:0)
echo "
<table border='1'>
<th>Site Name:</th>
<th>Category:</th>
<th>RSS:</th>";
应该是:
echo "
<table border='1'>
<tr>
<th>Site Name:</th>
<th>Category:</th>
<th>RSS:</th>
</tr>";
首先。
答案 2 :(得分:0)
或者只是使用像SDTable.com或jqGrid这样的工具让他们为你完成所有工作=)