<table width="100%" cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse;" bordercolor="#CCCCCC">
<tr><td height="30">标题</td><td>发布者</td><td>发布时间</td></tr>
<?php
$result=mysql_query("select * from liuyanlist");
while($row=mysql_fetch_row($result))
{
$id=$row->id;
?>
<tr height="30"><?php echo $id ?><td></td><td></td><td></td></tr>
<?php
}
?>
<tr><td></td><td colspan="2" height="30" style="text-align:right; padding-right:20px;"><a href="index.php?act=tianjia">添加</a></td></tr>
</table>刚学,以上是代码如果我
$result=mysql_query("select * from liuyanlist");
print_r(mysql_fetch_row($result));
while($row=mysql_fetch_row($result))就会发现上面多了Array ( [0] => 1 [1] => ?????????? [2] => ?????????? [3] => 0000-00-00 [4] => 0 [5] => [6] => 0000-00-00 ) 说明这里有内容啊。可我的内容显示的时候,怎么一个都没出来啊。白板的。。

解决方案 »

  1.   

    while($row=mysql_fetch_row($result))
    {
    $id=$row['id'];或者
    while($row=mysql_fetch_object($result))
    {
    $id=$row->id;
      

  2.   

    错了,用,mysql_fetch_array();while($row=mysql_fetch_array($result))
    {
    $id=$row['id'];
    否者你的是数字索引。
    或者用
    while($row=mysql_fetch_object($result))
    {
    $id=$row->id;
      

  3.   

    我...
    你敢写的有规则点吗?
    这样嵌入 有时候很容易出错。
    看了半天才明白。$result = mysql_query("select * from liuyanlist");
    while($row = mysql_fetch_array($result))
      {
      echo $row['id'];
      }这样循环出来的就是ID了
      

  4.   

    现在来公布答案吧。mysql_fetch_row
    返回的只能用数字作为索引的,也就是$row[0],$row[1]mysql_fetch_array 返回的索引也行。字段名也行。最重要的是

    注: mysql_fetch_array()函数返回的字段名是大小写敏感的。
    谢谢大家的指导!