I'm very new to PHP, and apologies if this is covered elsewhere.
I'm not getting any errors, it's just not doing what I would like it to.
I have some PHP that generates a monthly calendar table, depending on month and year selections from a drop down box.
The page also runs an SQL query to retieve event information from a MySQL database. The info is stored in an array.
What I'm trying to do is when it creates the table cell for a day, it checks the array to see if there is an event for that day and puts the title in if there is. I managed to make it work by running the query for each day, but this presents the database with 30/31 queries for a month, not a good way to do it.
It creates the full month, it just doesn't place any event info in the days.
This is part of the SQL Query (generated in Dreamweaver)
Code: Select all
mysql_select_db($database_calendar, $calendar);
$query_events = sprintf("SELECT event_id, Username, ent_title, MONTH(date), RIGHT(date,2) FROM calendar WHERE Username = '%s' AND MONTH(date) = '%s' ", $colname_events,$eventMonth_events);
$query_limit_events = sprintf("%s LIMIT %d, %d", $query_events, $startRow_events, $maxRows_events);
$events = mysql_query($query_limit_events, $calendar) or die(mysql_error());
$row_events = mysql_fetch_assoc($events);Code: Select all
//Setup event array.
$event_array = array($newDay, $entry);
//Link added to pass url parameters to add event page.
print ">$daycount<br><a href="add_event.php?eventDate=$year-$month-$daycount">Add</a><br>\n";
if ($newDay == $daycount) {
while ($row = mysql_fetch_array($row_events)) {
print "<a href="event_details?event_id=$event_id">$entry</a></td>\n";}
}
Else {print "</td>\n";}
}
// close table row if it is saturdayThanks in advance for any help and advice.