Event Manager In PHP

Hi!I am a newbie in PHP & have got a task of making event manager in PHP that too with different user levels. The problem is I cant find the exact code I am looking for. Can anyone please guide me how to display the events from database according to the user level??:frowning:

You might want to have a look at Access Control Lists. These allow you to assign different permission levels to users and display content according to their permission level.

There are a lots of solutions out there.

Problem is not with access levels but with the calendar and event display

Can you provide some code example of how user access is determined… this will help us understand the problem a bit better. There are many ways that user access could be implemented so until we know which one you are using its a bit tricky to help.

Ty

<?PHP
$user=$_GET['level'];
$id=$_GET['id'];
if($user=="1")
{
$query=mysql_query("SELECT * FROM mssgs WHERE uid='".$id."'");
}
// ..& so on
?>

I found the following code which is simple to change but it is using external XML file and I dont know a damn about XML :x

<?
if (!isset($_GET['year']))
{
$year = date(Y);
}
// otherwise, save this POST data under a simpler variable name
else 
{
$year = $_GET['year'];
}
// get the month number (1-12) if one not provided
if (!isset($_GET['monthNo'])) {
$monthNo = date(n);
}
// otherwise, save this POST data under a simpler variable name
else {
$monthNo = $_GET['monthNo'];
}
// get current month name
$monthName = date(F, mktime(0, 0, 0, $monthNo, 1, $year));
// get the number of days in this month
$daysInMonth = date(t, mktime(0, 0, 0, $monthNo, 1, $year));
// get XML data
//$data = implode("", file($xmlFile));
// create XML parser
//$parser = xml_parser_create();
// set parser options
//xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
//xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
// parse XML data into arrays
//xml_parse_into_struct($parser, $data, $values, $tags);
// free parser
//xml_parser_free($parser);
// set variables for cycling through parsed XML data
$i = 0; // set the array counter variable
$lookForMonth = 0; // set default to false
$getDays = 0; // set default to false
// cycle through parsed XML data
while ($i < count($values)) {
// if close tag of current month and year, stop cycle
if ($getDays && $values[$i][tag] == $monthName) {
break;
}
// if open tag of current year, start looking for current month 
if ($values[$i][tag] == "Y$year" && $values[$i][type] == "open") {
$lookForMonth = 1;
}
// get days
if ($getDays) {
// get day number from tag name
$day = $values[$i][tag];
// cut "D" off tag name
$day = substr($day, 1);
// put day number as key and event description as value in new array
$event[$day] = $values[$i][value];
}
// if tag of current month, start getting days
if ($lookForMonth && $values[$i][tag] == $monthName) {
$getDays = 1;
}
// increment counter
$i++;
}
// PRINT CALENDAR
// print the HTML document header
echo "<html>\
\
";
echo "<head>\
";
echo "<title>Calendar</title>\
";
echo "<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"calendar.css\\">\
";
echo "</head>\
\
";
echo "<body>\
";
// print the calendar table head
echo "<table align=\\"center\\">\
";
echo "<caption>$monthName $year</caption>\
";
echo "<tr>\
";
echo "\	<th>Sunday</th>\
";
echo "\	<th>Monday</th>\
";
echo "\	<th>Tuesday</th>\
";
echo "\	<th>Wednesday</th>\
";
echo "\	<th>Thursday</th>\
";
echo "\	<th>Friday</th>\
";
echo "\	<th>Saturday</th>\
";
echo "</tr>\
";
// for each day of the month
for ($dayNo = 1; $dayNo <= $daysInMonth; $dayNo++) {
// get the day name
$dayName = date(D, mktime(0, 0, 0, $monthNo, $dayNo, $year));
// if the first day of the month is not Sunday
if ($dayNo == 1 && $dayName != "Sun") {
// start a new row
echo "<tr>\
";
// get the day of the week number (0-6)
$dayOfWeek = date(w, mktime(0, 0, 0, $monthNo, $dayNo, $year));
// print empty table cells until we reach the first day of the month
for ($i = 0; $i < $dayOfWeek; $i++) {
echo "\	<td></td>\
";
}
}
// if Sunday, start a new row
if ($dayName == "Sun") {
echo "<tr>\
";
}
// if event exists for this day, print day cell with event
if (isset($event[$dayNo])) {
echo "\	<td class=\\"event\\"><b>$dayNo</b> $event[$dayNo]</td>\
";
}
// otherwise, print day cell without event
else {
echo "\	<td><b>$dayNo</b></td>\
";
}
// if Saturday, close this row
if ($dayName == "Sat") {
echo "</tr>\
";
}
// if the last day of the month is not Saturday
if ($dayNo == $daysInMonth && $dayName != "Sat") {
// get the day of the week number (0-6)
$dayOfWeek = date(w, mktime(0, 0, 0, $monthNo, $dayNo, $year));
// print empty table cells until we reach Saturday
for ($i = 6; $i > $dayOfWeek; $i--) {
echo "\	<td></td>\
";
}
// close this row
echo "</tr>\
";
}
}
// close the table
echo "</table>\
";
echo "<br>\
";
// PRINT NAVIGATION MENU
// calculate previous month
$prevMonth = $monthNo - 1;
// if previous month number is 0, reset to 12 and decrement year
if ($prevMonth == 0) {
$prevMonth = 12;
$prevYear = $year - 1;
}
// otherwise, keep same year
else {
$prevYear = $year;
}
// calculate next month
$nextMonth = $monthNo + 1;
// if next month number is 13, reset to 1 and increment year
if ($nextMonth == 13) {
$nextMonth = 1;
$nextYear = $year + 1;
}
// otherwise, keep same year
else {
$nextYear = $year;
}
// get previous month name
$prevMonthName = date(F, mktime(0, 0, 0, $prevMonth, 1, $prevYear));
// get next month name
$nextMonthName = date(F, mktime(0, 0, 0, $nextMonth, 1, $nextYear));
// print links for previous and next months
echo "<p align=\\"center\\">[ <a href=\\"?year=$prevYear&monthNo=$prevMonth\\"><< $prevMonthName</a> | <a href=\\"?year=$nextYear&monthNo=$nextMonth\\">$nextMonthName >></a> ]</p>\
";
// print the HTML document footer
echo "</body>\
\
";
echo "</html>";
?>

It displays events in following code:

// if event exists for this day, print day cell with event
if (isset($event[$dayNo])) {
echo "\	<td class=\\"event\\"><b>$dayNo</b> $event[$dayNo]</td>\
";
}
// otherwise, print day cell without event
else {
echo "\	<td><b>$dayNo</b></td>\
";
}

But the values are posted through XML and not PHP.
I need desperate help with the query where I can check whether the day has events and print it on that too according with the user level.

Well, you can check a users level like this


if ($user == "1") {
 // Do something that a user with level 1 access can do
}

I have to say, I am still a little confused what you are asking… it looks like you already have some access control in place.

yeh I have a login panel through which a user access the data. If user is admin, he can access all the data in the event calender.
So if user level==1, all events from the database have to display which I have saved in mysql database.