$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
$rs2 = mysql_query($query2) or die(mysql_error());
$row_rs2 = mysql_fetch_array($rs2);
echo $row_rs2[boardid];trying
应该用$row_rs2['boardid']吧
究竟怎样取
...
$row_rs2['ttttt'] or
$row_rs2["ttttt"]
$rs2 = mysql_query($query2) or die(mysql_error());
$row_rs2 = mysql_fetch_array($rs2);
echo $row_rs2['maxboardid'];再试。
各位还有什么办法
改为这样:$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");再试。
$row_rs2 = mysql_fetch_array($rs2);
print_r($row_rs2); // 看一下都输出些什么
正确取回max(boardid)字段方法:
$row_rs2['max(boardid)']十分感谢你的提示
经过print_r()函数才知道纪录集下标为max(boardid)
有机会再交流,交个朋友吧
在php里面$row_rs2['maxboardid']出错
用$row_rs2['max(boardid)']才可以
原来你在查询语句定义了max(boardid) as maxboardid
$row_rs2['maxboardid']照样正确$query2= "Select max(boardid) AS maxboardid from news where sectionid='$sectionid' and type='$type' ";