0

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??

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by anita_86
0

You need to provide a much clearer definition of the requirement. It isn't clear what "an event" is or what user levels have to do with it. It may not be realistic to think that you will find the exact code you need. If this is your business or school project, then we would expect you to create some code and if you run into problems, then you can ask some specific questions.

0
<?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

<?
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>\n\n";
echo "<head>\n";
echo "<title>Calendar</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"calendar.css\">\n";
echo "</head>\n\n";
echo "<body>\n";
// print the calendar table head
echo "<table align=\"center\">\n";
echo "<caption>$monthName $year</caption>\n";
echo "<tr>\n";
echo "\t<th>Sunday</th>\n";
echo "\t<th>Monday</th>\n";
echo "\t<th>Tuesday</th>\n";
echo "\t<th>Wednesday</th>\n";
echo "\t<th>Thursday</th>\n";
echo "\t<th>Friday</th>\n";
echo "\t<th>Saturday</th>\n";
echo "</tr>\n";
// 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>\n";
// 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 "\t<td></td>\n";
}
}
// if Sunday, start a new row
if ($dayName == "Sun") {
echo "<tr>\n";
}
// if event exists for this day, print day cell with event
if (isset($event[$dayNo])) {
echo "\t<td class=\"event\"><b>$dayNo</b> $event[$dayNo]</td>\n";
}
// otherwise, print day cell without event
else {
echo "\t<td><b>$dayNo</b></td>\n";
}
// if Saturday, close this row
if ($dayName == "Sat") {
echo "</tr>\n";
}
// 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 "\t<td></td>\n";
}
// close this row
echo "</tr>\n";
}
}
// close the table
echo "</table>\n";
echo "<br>\n";
// 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>\n";
// print the HTML document footer
echo "</body>\n\n";
echo "</html>";
?>

It displays events in following code:

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

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.
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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.