Reply
Problems with PHP Calendar
Old 03-09-2007, 04:48 AM Problems with PHP Calendar
Junior Talker

Posts: 2
Name: Andy
Hi there,

I'm having trouble with a PHP calendar script I'm trying to create for my new employers. Basically, users enter events via a script and then the calendar dynamically displays the events on the particular date, and provides a link to the full details of the event. However, I'm having trouble getting the calendar to display all the events. I can get it to display one, but I'm having a bit of a mental block in terms of how to get the rest to display. This is where you magical, wonderful, brilliant people swoop in to save the day

Here is a code segment:

php:for( $counter = 1; $counter <= $numdaysinmonth; $counter ++ )
{


$rowcounter ++;

if($counter)
{
$dayVal = $getEventArray['evtDay'];
$dayQuery = "SELECT evtName FROM event_table WHERE evtDay = '$dayVal'";
$dayResult = mysql_query($dayQuery) or die ("Problem with query: " . mysql_query());
$dayArray = mysql_fetch_array($dayResult) or die ("Problem with fetch: " . mysql_query());
if($dayVal == $initial)
{
$task = $dayArray['evtName'];
printf("This is a test: %s ", $dayVal);
}
elseif($dayVal != $initial)
{
$task = "";
}

printf("tt<td>%s - %s</td>n", $counter, $task);
$initial ++;
next($getEventArray);
printf("Last DayVal = %s", $getEventArray['dayVal']);
}
else
{
print("this is the else");
echo "tt<td>$counter</td>n";
}
?>



The full code is here: www.andyseaton.co.uk/testCalendar.txt

and a sample of the working calendar: www.andyseaton.co.uk/testCalendar.php

Basically, what I want is the counter to increment through the days of the month, and if it hits any of the values in the array (which is taken from the events table) it prints both the day number and the event details.

so if there were three events from the month of march, on the 12th, 14th and 21st, for example, the array values would be {12, 14, 21} I can get the first one to display, as shown in the calendar just now, but I cannot get it to iterate to the next value in the array. I have tried to use next() and each() but those do not seem to work.

I would appreciate any light that people could shed on this issue.

Cheers

Andy
andy2006 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-09-2007, 08:30 AM Re: Problems with PHP Calendar
jito's Avatar
L

Posts: 550
Name: surajit ray
Location: inside the heart of my friends
You have the problem in:
$getEventArray = mysql_fetch_array($getEventResult); Line 107
you never loop throug the records, there is only one date in $getEventArray.

Try :
PHP Code:
$getEventArray=array();
 while(
$row mysql_fetch_array($getEventResult))
  {
   
array_push($getEventArray,$row[0]);
  } 
One another thing, always use php tag while posting.
__________________
Take care about what you think. Thoughts can travel far - Swami Vivekananda
jito is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problems with PHP Calendar
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12054 seconds with 13 queries