Jump to content

[SOLVED] inserting from sql to array


sarahAria

Recommended Posts

I have the data for a class in below table (it's a class schedule and it draws the array on the week array)

CREATE TABLE schedule(
program TEXT NOT NULL,
duration TEXT NOT NULL,
day TEXT NOT NULL,
clock TEXT NOT NULL
);

 

& I need an array that should be like below (If I write below the array works)

$classes_arr = array(
    // Classes for monday (day 1)
    $r[day] => array(
            $r[clock] => array(
                "html" => ".$r[program].", 
                "style" => "background-color: #66CCCC", // use style property to change the background color
                "interval" => $r[duration] // set the interval for 2hrs
            )
    )
);

 

now I need to put data from sql to the array ND PRODUCE AN ARRAY LIKE above one

the final code should be like this

...
$classes_arr = array();
while ($row=mysql_fetch_assoc($result)) {
    extract($row);
    $classes_arr = array(
        $day => array(
            'clock' => '$clock',
            'html' => '$program',
            'style' => "background-color: #66CCCC",
            'interval' => '$duration') );
}

but it doesn't work any help? :'(

thanks Sarah

Link to comment
https://forums.phpfreaks.com/topic/126436-solved-inserting-from-sql-to-array/
Share on other sites

there seems to be an error with array cause even by replacing values with constants nothing changes?!!?

unfortunately I don't know much about arrays  :'(

 

$classes_arr = array();
while ($row=mysql_fetch_assoc($result)) {
    extract($row);
    $classes_arr = array(
        0 => array(
            12 => array (
            'html' => '$program',
            'style' => "background-color: #66CCCC",
            'interval' => '120') ));

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.