Jump to content

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...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.