如何创建一个mysql结果数组,其行中具有一定的值

I have following code:

<?php
include_once 'init/init.funcs.php';
$pollid=$_GET['pollid'];
$result = mysql_query('SELECT question FROM questions where survey_id="' . $pollid . '"');
$question = mysql_result($result, 0);
echo $pollid;
echo $question;

?>

And it will echo first question which has survey_id=$pollid. But I want to make an array of all the questions, which have survey_id=$pollid.How I can do that?

Just loop through the results and add them to an array:

$pollid = (int) $_GET['pollid'];
$questions = array();
$result = mysql_query('SELECT question FROM questions where survey_id="' . $pollid . '"');
while($row = mysql_fetch_assoc($result)) {
    $questions[$pollid] = $row['question '];
}

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.

You are also wide open to SQL injections. In my example I casted $_GET['pollid'] to an integer to help protect against them. A better approach would be to use prepared statements as mentioned above.

Try to use mysqli_ instead of mysql_,

// MYSQLI
$mysqli = new mysqli('localhost', 'example', 'example', 'test');

print '<h3>MYSQLI: simple select</h3>';
$rs = $mysqli->query( YOUR SELECT QUERY);
while($row = $rs->fetch_object())
{
    //DATA
}