473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Restriction in Adding Events in Calendar

i want to share my problem in my website

For the better understandng of my website, I want to tell all the details.

1. I have a database and i has a 2 tables 1 for the tbllogin which consist of Username and Department, and the second table is caltbl which i use for the calendar events.

2.When my website run the first webpage is the login form. If the Username and Department is correct she can browse the other webpages, like the calendar event.


3. In the calendar event you can see the calendar and when you click the date theirs a link "new event" appear and if theirs no existing event theres a text saying "No Events", when you click the link you can add events. I want that theirs a specific person that can only add events for the restriction of adding events. I want to happen that if the user is xxx and her department is yyy the link shoud appear and she can add events. i want that only to her the link should be appear..

here is my code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $host = "localhost";
  3.  
  4.     $username = "";
  5.  
  6.     $password = "";
  7.  
  8.     $dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database');
  9.  
  10.     $dbName = 'dspi';
  11.  
  12.     mysql_select_db($dbName);    
  13. ?>
  14. <script>
  15. function goLastMonth(month, year){
  16. // If the month is January, decrement the year
  17. if(month == 1){
  18. --year;
  19. month = 13;
  20. }
  21. document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;
  22. }
  23. //next function
  24. function goNextMonth(month, year){
  25. // If the month is December, increment the year
  26. if(month == 12){
  27. ++year;
  28. month = 0;
  29. }
  30. document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;
  31.  
  32. function remChars(txtControl, txtCount, intMaxLength)
  33. {
  34. if(txtControl.value.length > intMaxLength)
  35. txtControl.value = txtControl.value.substring(0, (intMaxLength-1));
  36. else
  37. txtCount.value = intMaxLength - txtControl.value.length;
  38. }
  39.  
  40. function checkFilled() {
  41. var filled = 0
  42. var x = document.form1.calName.value;
  43. //x = x.replace(/^\s+/,""); // strip leading spaces
  44. if (x.length > 0) {filled ++}
  45.  
  46. var y = document.form1.calDesc.value;
  47. //y = y.replace(/^s+/,""); // strip leading spaces
  48. if (y.length > 0) {filled ++}
  49.  
  50. if (filled == 2) {
  51. document.getElementById("Submit").disabled = false;
  52. }
  53. else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased
  54.  
  55. }
  56.  
  57. </script>
  58. <html>
  59. <body>
  60. <?php
  61. //$todaysDate = date("n/j/Y");
  62. //echo $todaysDate;
  63. // Get values from query string
  64. $day = (isset($_GET["day"])) ? $_GET['day'] : "";
  65. $month = (isset($_GET["month"])) ? $_GET['month'] : "";
  66. $year = (isset($_GET["year"])) ? $_GET['year'] : "";
  67. //comparaters for today's date
  68. //$todaysDate = date("n/j/Y");
  69. //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : "";
  70. //$what = (isset($_GET["what"])) ? $_GET['what'] : "";
  71.  
  72. //$day = (!isset($day)) ? $day = date("j") : $day = "";
  73. if(empty($day)){ $day = date("j"); }
  74.  
  75. if(empty($month)){ $month = date("n"); }
  76.  
  77. if(empty($year)){ $year = date("Y"); } 
  78. //set up vars for calendar etc
  79. $currentTimeStamp = strtotime("$year-$month-$day");
  80. $monthName = date("F", $currentTimeStamp);
  81. $numDays = date("t", $currentTimeStamp);
  82. $counter = 0;
  83. //$numEventsThisMonth = 0;
  84. //$hasEvent = false;
  85. //$todaysEvents = ""; 
  86. //run a selec statement to hi-light the days
  87. function hiLightEvt($eMonth,$eDay,$eYear){
  88. //$tDayName = date("l");
  89. $todaysDate = date("n/j/Y");
  90. $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;
  91. if($todaysDate == $dateToCompare){
  92. //$aClass = '<span>' . $tDayName . '</span>';
  93. $aClass='class="today"';
  94. }else{
  95. //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear;
  96. //echo $todaysDate;
  97. //return;
  98. $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'";
  99. //echo $sql;
  100. //return;
  101. $result = mysql_query($sql);
  102. while($row= mysql_fetch_array($result)){
  103. if($row['eCount'] >=1){
  104. $aClass = 'class="event"';
  105. }elseif($row['eCount'] ==0){
  106. $aClass ='class="normal"';
  107. }
  108. }
  109. }
  110. return $aClass;
  111. }
  112. ?>
  113. <div id="Calendar_Event">
  114. <table width="350" cellpadding="0" cellspacing="0">
  115. <tr>
  116. <td width="50" colspan="1">
  117. <input type="button" value=" < " onClick="goLastMonth(<?php echo $month . ", " . $year; ?>);">
  118. </td>
  119. <td width="250" colspan="5">
  120. <span class="title" style="color:#FFFFFF"><?php echo $monthName . " " . $year; ?></span><br>
  121. </td>
  122. <td width="50" colspan="1" align="right">
  123. <input type="button" value=" > " onClick="goNextMonth(<?php echo $month . ", " . $year; ?>);">
  124. </td>
  125. </tr> 
  126. <tr>
  127. <th>M</td>
  128. <th>T</td>
  129. <th>W</td>
  130. <th>T</td>
  131. <th>F</td>
  132. <th>S</td>
  133. <th>S</td>
  134. </tr>
  135. <tr>
  136. <?php
  137. for($i = 1; $i < $numDays+1; $i++, $counter++){
  138. $dateToCompare = $month . '/' . $i . '/' . $year;
  139. $timeStamp = strtotime("$year-$month-$i");
  140. //echo $timeStamp . '<br/>';
  141. if($i == 1){
  142. // Workout when the first day of the month is
  143. $firstDay = date("N", $timeStamp);
  144. for($j = 1; $j < $firstDay; $j++, $counter++){
  145. echo "<td>&nbsp;</td>";
  146. }
  147. if($counter % 7 == 0 ){
  148. ?>
  149. </tr><tr>
  150. <?php
  151. }
  152. ?>
  153. <!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> 
  154. <?php
  155. }
  156. ?>
  157. </table>
  158. </div>
  159. <div id="New_Event">
  160. <?php
  161. if(isset($_GET['v'])){
  162. if(isset($_POST['Submit'])){
  163. $sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";
  164. mysql_query($sql);
  165. }
  166. $sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";
  167. //echo $sql;
  168. //return;
  169. $result = mysql_query($sql);
  170. $numRows = mysql_num_rows($result);
  171.  
  172. $check=mysql_query("SELECT * FROM tbllogin WHERE Username='rhoda.barrera@dunlop.ph' AND Department='MIS'");
  173. if (mysql_num_rows($check)>0){ 
  174. ?>
  175. <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">Add Even</a><a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">t</a><?php
  176. }else{
  177. echo 'You cannot Add New Event';
  178. }?>
  179. </div>
  180. <div id="Cal_Event">
  181. <?php
  182. if(isset($_GET['f'])){
  183. include 'calForm.php';
  184. }
  185. if($numRows == 0 ){
  186. echo '';
  187. }else{
  188. //echo '<ul>';
  189. echo '<h3>Event Listed</h3>';
  190. while($row = mysql_fetch_array($result)){
  191. ?>
  192.  
  193. <h5><?=$row['calName'];?></h5>
  194. <?=$row['calDesc'];?><br/>
  195. Listed On: <?=$row['calStamp'];?>
  196. <?php
  197. }
  198. }
  199. }
  200. ?>
  201. </div>
  202. </body>
  203. </html>
  204.  
Sep 9 '10 #1
1 1249
dlite922
1,584 Expert 1GB
You can want alot of things, but in the end you'll be the one to code it.

Attack one problem at a time and ask specific questions related to that problem but first make sure you've done your own research, attempted to fix it as many ways as you can think of, and know how to accurately describe the problem (errors, expected output, where it fails, etc)

All these things are missing in your post that's why you have not gotten a response yet.


Dan
Sep 22 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: middletree | last post by:
I know I have seen some free ASP calendars before, and even did a search of this NG, but couldn't find any references to any. I went to 4guysfromrolla and asp101, but they only .NET calendars as...
3
by: Luis E Valencia | last post by:
I have a table that says for example 01/05/2004 Party IIsadpaks 01/06/2004 Party 2394923423 A events table. I want to make a calendar and that the days that are events are inbold and with...
2
by: JezB | last post by:
I'm adding WebControl objects to a Page dynamically on Page_Load, but I'm having trouble attaching events to these. For example, adding an image button :- ImageButton nb = new ImageButton();...
2
by: Oddball | last post by:
I am trying to create and add a number of ImageButtons to a page when a certain event is called. Not only am I suffering from my page running the "Page_Load" event three times, but I can't seem...
5
by: Mark Rae | last post by:
Hi, Is it possible to add events, specifically a Click event, to a dynamically created TableCell? I have an <asp:Table...> control to which I'm dynamically adding TableRow controls made up of...
0
by: prabhupr | last post by:
Hi Folks Is there anybody who has a sample code which does provide the functionality of adding event/reminder from my ASPx page to Outlook calendar. For example, if you visit this site...
0
by: larry | last post by:
I am in the process of rewriting one of my first PHP scripts, an event calendar, and wanted to share the code that is the core of the new calendar. My current/previous calendar processed data...
2
by: rglaeser | last post by:
How do I add a calendar "box" to a Date and Tme field?
1
by: neosam | last post by:
Hi, Here I come again with my silly questions.... I am now working on a calendar control and i am able to put in the control and also link it to a field, but i keep getting a error message in VB...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.