Making a "repeat region" for a specific variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wkrauss
Forum Newbie
Posts: 3
Joined: Mon May 09, 2005 7:04 pm

Making a "repeat region" for a specific variable

Post by wkrauss »

What I am trying to accomplish is format a date from a database then have a specific array repeated for all records in the database. I have figured everything out except the repeating part.

Here's the basic code I started with:

Code: Select all

$days = array(
					$today=>array(NULL,'calendar-day',NULL,NULL.$today.'</span>'),
      			  9=>array('#','calendar-linked',NULL,NULL.'9'.'</span>'),
      			  10=>array('#','calendar-linked',NULL,NULL.'10'.'</span>'),
      			  11=>array('#','calendar-linked',NULL,NULL.'11'.'</span>'),
					);
Then I added the date formatting, recordset, and connection to database:

Code: Select all

$evtDate = $row_rsAppearances['Date'];
			list ($evtYear, $evtMonth, $evtDay) = explode ("-", $evtDate);
									
					$days = array(
					$today=>array(NULL,'calendar-day',NULL,NULL.$today.'</span>'),
      			  $evtDay=>array('#','calendar-linked',NULL,NULL.$evtDay.'</span>'),
					);
So now, rather than using "9" "10" and "11" it will use the values from the database ($evtDay). Only problem is I cant get it to repeat. It will only write the code of line 6 (in the 2nd php code box) one time rather than once for every date entry in the database. Any help would be much appreciated.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

try

Code: Select all

while($evtDate = $row_rsAppearances['Date']){

list ($evtYear, $evtMonth, $evtDay) = explode("-",$evtDate);
   $days = array(
   $today=>array(NULL,'calendar-day',NULL,NULL.$today.'</span>'),
   $evtDay=>array('#','calendar-linked',NULL,NULL.$evtDay.'</span>'));
}
Post Reply