Ok, I have the following code:
$query = "SELECT name FROM people WHERE age > 10 ";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
$namearr = mysql_fetch_array($result);
IF ($numrows > 0)
{
$names = implode(",", $namearr);
echo $names;
} ELSEIF ($numrows < 1) {
echo "No people";
}
What I want to do, is spit out the values from the selected rows as a comma separated list. Let's say the above query returns 3 rows with name values: "Sam", "Mike", and "Ben". I want to
print "Sam, Mike, Ben";
Yet, the above code is printing: "Sam, Sam"
Why? What have I missed?