Link to home
Start Free TrialLog in
Avatar of TLN_CANADA
TLN_CANADAFlag for Afghanistan

asked on

Getting array from database

Hi all,

I'm still learning PHP and am having some trouble creating an array that I can add the info to a PHP Chart.

Here is my call to the database.  

$query = mysql_query("SELECT * FROM exercising_table WHERE uname = '$username' ");

Open in new window


Field names:

uname
exercise_id (primary key)
exercise_duration (int in minutes)
exercise_timestamp

and I need to output the array in this format:

 
          ['24/01/12',  25],
          ['25/01/12',  26],
          ['28/01/12',  27],
          ['24/02/12',  25],
          ['15/03/12',  26],
          ['24/04/12',  27],
          ['21/06/12',  11]
        

Open in new window


The first column is the date (to be taken from exercise_timestamp) and the second column is the exercise time (to be taken from exercise_duration)

Could anyone assist me with this?

Thank you so much.
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rossdalangin
rossdalangin

$query = mysql_query("SELECT exercise_timestamp,exercise_duration FROM exercising_table WHERE uname = '$username' ");

while($row = mysql_fetch_array($query))
{
    $data[] = $row;
}