sql result as array of arrays

i'm trying to format the output of a sql query as an array of arrays, for using the gannti class graph tool on my sql data. I'm not very experienced(outside industrial plc's), and can't seem to find a solution to this particular problem despite lots of googeling.

The sql query i want to perform looks like this:

$query = "SELECT label, start, end from oppgaver ";

And the original array showed in the gannti class example is written like this:

$data = array();

data[] = array(
  'label' => 'alarmkit',
  'start' => '2013-08-01',
  'end'   => '2013-09-10'
);

$data[] = array(
  'label' => 'Stekeovnskontroller',
  'start' => '2013-08-22',
  'end'   => '2013-09-01'
);

$data[] = array(
  'label' => 'Tull og fanteri',
  'start' => '2013-09-02',
  'end'   => '2013-09-10'
);

And then you call the gantti to do it's thing:

$gantti = new Gantti($data, array(
  'title'      => 'Elektro',
  'cellwidth'  => 15,
  'cellheight' => 35,
  'today'      => true
));

All works well, except for my unability to format the sql output to what i assume is an array of arrays so the gantti class can do its magic. I got it to show the first letter of each label in the sql database once, but that piece of mangled code i wrote should probably be forgotten :-)

Does anyone here have a idea about how to do this?

Update:

The last way i tried to get the data, by using msql_fetch_assoc. Unfortunately i did not keep a record of the different approaches i made. I've also tried several examples i found on using mysql_fetch_array, and mysql_fetch_row.

$query = "SELECT label, start, end from oppgaver ";
$result = mysql_query($query);
$data = array();


while ($row = mysql_fetch_assoc($result)) {
        array_push($data, $row[0]);
        }

Answers


Use $row to push in array in place of $row[0]

As given below

while ($row = mysql_fetch_assoc($result)) {
        array_push($data, $row);
        }

Need Your Help

Regular expression to find unknown acronyms

ruby regex regex-negation acronym

I need a regular expression that will pick out lines with ALL CAPS or unknown acronyms.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.