I want to retrieve records from specific field from a MySQL table and build array.
Lets say I have field first_name in MySQL table and after using query
"SELECT first_name from family", get records like
Andy
Bob
Craig
Now I want them to be in this format of array
$names = array(1=>'Andy',
2=>'Bob',
3=>'Craig');
Now the problem I am facing is when I run this query using PHP
$query = "SELECT first_name FROM family ";
$result = mysql_query($query);
while($rows = mysql_fetch_array($result))
{
$names = $row['first_name'];
}
I don't want my variable (which stores the array) inside a while loop.....
Bookmarks