$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 ) ;

解决方案 »

  1.   

    你这个for语句没关闭?
    另外单引号里不能调用变量的
      

  2.   

    while(mysql_fetch_array($result)) {
    $i =0 ;
    '$row' . $i = mysql_fetch_array($result) ;
    $i++;
    }红色的部分依次就把数据提取完了,而你是想再第二次中提取数据,当然就是空的了。可以这样写:while($myResult = mysql_fetch_array($result)) {
    $i =0 ;
    '$row' . $i = $myResult ;
    $i++;
    }
      

  3.   

    其实sql语句这样写就行了:$sql = "select * from message where articleID= '$artID' order by id";
      

  4.   

    是这样的,我想先用一个变量:字符'XX‘连接变量$i=xxi,XXi=一条记录,然后用循环打印出变量数组xxi,可是我这样写,打印不出来,为什么?
      

  5.   

    $artID= "1";
    $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);