0

我需要用这样的东西从我的数据库中输出多行选择。它正在输出第二行但不是第一行,并返回警告“警告:非法字符串偏移量'char_name'”

$i = 0;
while($array = @mysql_fetch_assoc($query)){
    $row[$i] = $array;
    $char = $row[$i]['char_id'];
    $$char['char_name'] = $row[$i]['char_name'];  /warning is on this line

    echo $char . " " . $$char['char_name'];$i++;
}
4

2 回答 2

1

你能重建代码吗:

$i = 0;
while($array = @mysql_fetch_assoc($query)){
    $row[$i] = $array;
    $char = $row[$i]['char_id'];
    $char_name = $row[$i]['char_name']; 

    echo $char . " " . $char_name;
    $i++;
}
于 2013-10-24T06:09:04.920 回答
0

将此更改为

$$char['char_name'] = $row[$i]['char_name'];  /warning is on this line
echo $char . " " . $$char['char_name'];
$i++;

这个

$char['char_name'] = $row[$i]['char_name'];  /warning is on this line
echo $char . " " . $char['char_name'];
$i++;
于 2013-10-24T06:08:01.967 回答