Hi,
I need to build an array from a mysql resultset. The array will be in the form:
$array = Array ("one@dom.com", "two@dom.com", "tri@dom.com")
Here is my approach:
$query = "select email from db";
$result = mysql_db_query($db,$query,$connection);
$array = "array ("; // OPEN ARRAY
while($myrow = mysql_fetch_array($result)){
$email = $myrow["email"];
$array .= "\"".$email."\", ";
}
Once the loop is complete, I should have something like this:
$array = array ("one@dom.com", "two@dom.com", "tri@dome.com",
// I do not need the last "comma and space" at the end
$array = substr($array, -2);
$array .= ")"; // CLOSE ARRAY
To produce:
$array = Array ("one@dom.com", "two@dom.com", "tri@dom.com")
Unfortunately, when I do the following and then ECHO $array, I get something similar to this:
, ", ")
But when I echo $email, the values are printed.
I just need an idea about how to build my array from the mysql result.
Thx.
Richie.