Jump to content

automating from a database into an array


pgsjoe

Recommended Posts

I've been building this calendar for weeks now! One last step is all I need. I need to create this....

[code] $days = array(
        2=>array('/weblog/archive/2004/Jan/02','linked-day'),
        3=>array('/weblog/archive/2004/Jan/03','linked-day'),
        8=>array('/weblog/archive/2004/Jan/08','linked-day'),
        22=>array('/weblog/archive/2004/Jan/22','linked-day'),
    );
[/code]

What I need to have...
[code]
$days = array(
  //read database and if there is an event, of which there should be plenty...
       day of event=>array('$result = mysql query("SELECT * FROM `calendar` WHERE date is this date"),'linked-day' //I have no clue what this does),);
[/code]

Any ideas?
Link to comment
Share on other sites

[!--quoteo(post=355463:date=Mar 15 2006, 02:51 PM:name=Steveo31)--][div class=\'quotetop\']QUOTE(Steveo31 @ Mar 15 2006, 02:51 PM) [snapback]355463[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What is "date is this date", how are you getting those dates, etc?
[/quote]

Thank you for asking! Guess I should have worded it better.

WHERE date is this date...
is suppose to be
WHERE the date here is the same as the date pulled by the array.


Though, thinking about it a bit more, I don't think I necessarily need to have the dates in the array link to a new sql query. Simply making them targets that point to the ID number would be just fine. So, here's the updated..."what I need to create"

[code]$days = array(
  //read database and if there is an event, of which there should be plenty...
       day of event=>array('# . $id','linked-day' //I have no clue what this does),
);[/code]
Link to comment
Share on other sites

[!--quoteo(post=355482:date=Mar 15 2006, 04:21 PM:name=PGS JoE)--][div class=\'quotetop\']QUOTE(PGS JoE @ Mar 15 2006, 04:21 PM) [snapback]355482[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]$days = array(
  //read database and if there is an event, of which there should be plenty...
       day of event=>array('# . $id','linked-day' //I have no clue what this does),
);[/code]
[/quote]

Hrm.. array of arrays.. Good fun!

[code]
$days = Array();
while ($line = mysql_fetch_array($result)) {
   $days[$line[0]) = Array($line[1], $line[2]);
}
[/code]

For my little example, $line[0] is the day of the week, $line[1] is '# . $id' and $line[2] is 'linked-day' .. All of those values are returned from the database..

I think that gives you what you want?
Link to comment
Share on other sites

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.