Fwd: Re: [PHP-DB] numeric string to single digit array

[email protected] (Richard Dunne)
Newsgroups php.db
Message-ID <[email protected]>
Using this extract from http://ie.php.net/manual/en/control-structures.foreach.php
Amaroq
09-Mar-2008 06:40 
Even if an array has only one value, it is still an array and foreach will run it.

<?php
$arr[] = "I'm an array.";

if(is_array($arr))
{
    foreach($arr as $val)
    {
        echo $val;
    }
}
?>

The above code outputs:
I'm an array.
-------------------------------------
So if I use:

$query = "Select answer from answers where studentID='A123456789'"; 
$result = mysql_query($query,$connection) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
	foreach($row as $answer)
	{
		echo $answer . "\n";
	}
}
I thought I would be able to print out each array element, but I am not getting any output.  Has anyone got a better idea?
(unnamed) (message/rfc822, 2.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.