存储在数组php中

时间:2014-08-13 07:51:54

标签: php mysql

$question = mysql_query("SELECT * FROM `debonere_questions`", $this->db);

while($user_data[]=mysql_fetch_assoc($question)){
        $sub_question = mysql_query("SELECT * FROM `debonere_sub_question` WHERE`q_id`='".$user_data['q_id']."'", $this->db);

        while($user_data1=mysql_fetch_assoc($sub_question_result)){
            echo $user_data1['sub_question'];
        }
    }

我希望将它存储在一个数组中。

1 个答案:

答案 0 :(得分:0)

做那样的事

$question = mysql_query("SELECT * FROM `debonere_questions`", $this->db);
while($user_data[]=mysql_fetch_assoc($question)){
$sub_question = mysql_query(
   "SELECT * FROM `debonere_sub_question` WHERE `q_id`='".$user_data['q_id']."'",
      $this->db);
    while($user_data1=mysql_fetch_assoc($sub_question_result)){
        $array[] = $user_data1['sub_question'];
        }
}

你应该使用MySQLi或PDO。