此代码将输出显示为subject1 subject2 subject3 subject4
但我想将这些值存储在不同的变量中(例如$s1=[1],$s2[2],$s3[3],$s4[4]
),所以我在不同的函数中使用它们该怎么办?任何人都可以帮忙...
答案 0 :(得分:0)
$query = mysql_query("select `subject` from `markssub1` where `sname`='$user' AND `sid`='$id'");
$subjects = [];
while($row = mysql_fetch_array($query))
{
$subjects[] = $row['subject'];
}
foreach($subjects as $subject){
echo $subject . '\n';
}