Jump to content


Photo

automating from a database into an array


  • Please log in to reply
3 replies to this topic

#1 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 15 March 2006 - 05:37 PM

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

$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'),
    );


What I need to have...
$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),);


Any ideas?

#2 Steveo31

Steveo31
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSan Jose, CA

Posted 15 March 2006 - 08:51 PM

What is "date is this date", how are you getting those dates, etc?

#3 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 15 March 2006 - 09:21 PM

[!--quoteo(post=355463:date=Mar 15 2006, 02:51 PM:name=Steveo31)--][div class=\'quotetop\']QUOTE(Steveo31 @ Mar 15 2006, 02:51 PM) View Post[/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"

$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),
);


#4 XenoPhage

XenoPhage
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 15 March 2006 - 09:31 PM

[!--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) View Post[/div][div class=\'quotemain\'][!--quotec--]
$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),
);
[/quote]

Hrm.. array of arrays.. Good fun!

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

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?
--
[a href=\"http://blog.godshell.com\" target=\"_blank\"]XenoPhage[/a]
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Something mysterious is formed, born in the silent void. Waiting alone and unmoving, it is at once still and yet in constant motion. It is the source of all programs. I do not know its name, so I will call it the Tao of Programming.[/quote]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users