【发布时间】:2013-01-16 10:47:48
【问题描述】:
$result = mysql_query("select * from formtable") or die("Records could not be fetched");
while($row=mysql_fetch_row($result))
{
echo $row[0].$row[1].$row[2];
}
上面的代码运行完美。但我发现这个声明 -> echo $row[0].$row[1].$row[2] 有点太静态了。因为如果添加新列,我将不得不将代码修改为echo $row[0].$row[1].$row[2].$row[3]。
那么,我如何计算行的总列数以避免这样的问题?
【问题讨论】:
-
Reena 你想要列值还是想要表中的总行数?
-
print_r($row) 给你什么?