Hi how can i put data selected from a mysql table into a array. I am doing this so it can be put into a select form.

Member Avatar for Zagga

Hi nick3592,

If the data is in a string, you can explode() it into an array.


Zagga

This code shows simple example of query result and array.

<?
$q="select * from user";
$res = mysql_query($q);
while($sar = mysql_fetch_assoc($res))
{	
	$arr[]['username'] = $sar['username'];
}
echo '<pre>';
print_r($arr);
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.