Implode the query results (PHP)

Problem: Some times we need to implode the results of a query to use them in another query or for some other reason.

Solution:
include "connection.php"; $query="select * from country";
$result=mysql_query($query);
$array =array();
while($row=mysql_fetch_array($result))
{
$array[]=$row['country'];
}
$string=implode(",",$array);
echo $string;

No comments:

Post a Comment