$query2="Select max(boardid) from news where sectionid='$sectionid' and type='$type'";
$rs2 = mysql_query($query2) or die(mysql_error());
$row_rs2 = mysql_fetch_array($rs2);
echo $row_rs2[boardid];trying

解决方案 »

  1.   

    用$row_rs2[boardid]可以取回纪录???
    应该用$row_rs2['boardid']吧
      

  2.   

    两个都不行:$row_rs2['boardid'],$row_rs2[boardid]
    究竟怎样取
      

  3.   

    $query2="Select max(boardid) as ttttt from news where sectionid='$sectionid' and type='$type'";
    ...
    $row_rs2['ttttt'] or
    $row_rs2["ttttt"]
      

  4.   

    改为这样:$query2="Select max(boardid) AS maxboardid from news where sectionid='$sectionid' and type='$type'";
    $rs2 = mysql_query($query2) or die(mysql_error());
    $row_rs2 = mysql_fetch_array($rs2);
    echo $row_rs2['maxboardid'];再试。
      

  5.   

    echo $row_rs2['maxboardid'];还是不行
    各位还有什么办法
      

  6.   

    到mysql提示符下执行你的"Select max(boardid) AS maxboardid from news where sectionid='$sectionid' and type='$type'"替换变量以后的实际语句 不要在程序上找毛病了echo $row_rs2['maxboardid']这个应该没有问题
      

  7.   

    是不是没有符合条件的记录?
    改为这样:$query2="Select max(boardid) AS maxboardid from news where sectionid='$sectionid' and type='$type'";
    $rs2 = mysql_query($query2) or die(mysql_error());
    $row_rs2 = mysql_fetch_array($rs2);
    echo $row_rs2['maxboardid'];$rows = mysql_num_rows($rs2);
    print("符合条件的记录数:$rows");再试。
      

  8.   

    $rs2 = mysql_query($query2, $uadmin) or die(mysql_error());
    $row_rs2 = mysql_fetch_array($rs2);
    print_r($row_rs2); // 看一下都输出些什么
      

  9.   

    to: xuzuning(唠叨) 
    正确取回max(boardid)字段方法:
    $row_rs2['max(boardid)']十分感谢你的提示
    经过print_r()函数才知道纪录集下标为max(boardid)
    有机会再交流,交个朋友吧
      

  10.   

    是可以用$row_rs2['max(boardid)']来取,但在SQL语句里设了别名(max(boardid) AS maxboardid)后用$row_rs2['maxboardid']来取也应该是不会错的呀!如果有符合条件的记录的话。
      

  11.   

    to ynredriver(红河):
    在php里面$row_rs2['maxboardid']出错
    用$row_rs2['max(boardid)']才可以
      

  12.   

    to  ynredriver(红河):  对不起,疏忽,你的也正确
    原来你在查询语句定义了max(boardid) as maxboardid
    $row_rs2['maxboardid']照样正确$query2=  "Select  max(boardid)  AS  maxboardid  from  news  where  sectionid='$sectionid'  and  type='$type'  ";