数组函数由id

时间:2015-08-13 21:10:44

标签: php arrays function loops

我想按问题编号更改数组的工作 例如:$array[$qssr['id']] 因为我把它们放在循环中 例如:foreach ($array[$qssr['id']] as &$value)

数组的值

$answers1 = mysql_query("select * from answers where qid='".$qnid."' LIMIT 0, 1") or die("error");
$answersr1 = mysql_fetch_assoc($answers1);

我的实验失败了:

function get_answer($qid)
{
    $answers = mysql_query("select * from answers where qid='".$qid."' LIMIT 0, 1") or die("error");
    $answersr = mysql_fetch_assoc($answers);

    $arr= array();

    foreach($answersr as $v)
    {
        $arr[] = $v['answer'];
    }
}

   $array = array();


$qss = mysql_query("select * from qs where sid='$finalsid' order by id asc") or die("error");
$qssr = mysql_fetch_assoc($qss);


    $qanswer = get_answer($qssr['id']);


    $array[$qssr['id']] = $q_answer;



foreach ($array[$qssr['id']] as &$value)

0 个答案:

没有答案