Jump to content

[SOLVED] Turning Mysql results into a SINGLE array with multple elements?


galvin

Recommended Posts

I have this simple mysql query bringing back just TWO items (1986 and 1990)...

$sql = "SELECT item
FROM quizitems
WHERE quizid = $quizid";
$result = mysql_query($sql, $connection);
if (!$result) { 
die("Database query failed: " . mysql_error());
} else {

while ($singlearray = mysql_fetch_array($result, MYSQL_NUM)) {
print_r($singlearray);
}

 

But that gives the following output, i.e. TWO, SEPARATE one element arrays...

 

Array ( [0] => 1986 ) Array ( [0] => 1990 ) 

 

Instead, I just want ONE single array with TWO elements in it, which would look something like this...

 

Array ( [0] => 1986, [1] => 1990 ) 

 

How do I do that?  This has to be easy but I'm going nuts trying to figure it out.  ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.