$artID= "1";
$act = $_SESSION['sign'];
$sql = "select * from message where articleID= '".$artID."' order by id";
$result = mysql_query($sql);
$j = 0;
while(mysql_fetch_array($result)) {
$i =0 ;
'$row' . $i = mysql_fetch_array($result) ;
$i++;
}
for($i=0;$i<5;$i++){
$j = $i+1;
$time = '$row' . $i['time'];
$text = '$row' . $i['messages'];
$replyID = '$row' . $i['replyID'];
$name = '$row' . $i['usname'] ;
$ID = '$row' . $i['Id'] ;
print_r('$row'.$i ) ;
$act = $_SESSION['sign'];
$sql = "select * from message where articleID= '".$artID."' order by id";
$result = mysql_query($sql);
$j = 0;
while(mysql_fetch_array($result)) {
$i =0 ;
'$row' . $i = mysql_fetch_array($result) ;
$i++;
}
for($i=0;$i<5;$i++){
$j = $i+1;
$time = '$row' . $i['time'];
$text = '$row' . $i['messages'];
$replyID = '$row' . $i['replyID'];
$name = '$row' . $i['usname'] ;
$ID = '$row' . $i['Id'] ;
print_r('$row'.$i ) ;
另外单引号里不能调用变量的
$i =0 ;
'$row' . $i = mysql_fetch_array($result) ;
$i++;
}红色的部分依次就把数据提取完了,而你是想再第二次中提取数据,当然就是空的了。可以这样写:while($myResult = mysql_fetch_array($result)) {
$i =0 ;
'$row' . $i = $myResult ;
$i++;
}
$act = $_SESSION['sign'];
$sql = "select * from message where articleID= '".$artID."' order by id";
$result = mysql_query($sql);
$row = array()
while($row[] = mysql_fetch_array($result)){
}
print_r($row);