jeudi 10 avril 2014

PHP - from DB to Array format


Vote count:

0




I am trying to extract data using PHP from a MySQL db.

I want to take the 'PersonName' column and 'Count' column and place them into an array.


PHP Code (so far):



$result = mysqli_query($con, --SQL CODE HERE--);

while($row = mysqli_fetch_array($result))
{
$data = $row['colName'];
}


I want to obtain an array (or 2 arrays) that contain the data from the 2 columns mentioned above.


I need it to be in either of the following formats:

1. One-Array Solution: [['Fred', 3], ['Bob', 5], ['Ted', 10]]

2. Two-Array Solution: ['Fred', 'Bob', 'Ted'] & [3, 5, 10]



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire