Guest User

Untitled

a guest
Jul 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. <?php //$timestamp=strtotime("2009-03-12 12:30:00");
  2.  
  3. $seatLimit=10;
  4.  
  5. function getScheduled($email, $eventId)
  6. {
  7. //REMOVE RECORD BY EMAIL
  8. require('config.php');
  9. $db=mysql_connect($h, $u, $p);
  10. mysql_select_db($d, $db);
  11.  
  12. $queryDates="SELECT * FROM scheduled WHERE email='".$email."' AND event_id='".$eventId."'";
  13. $q=mysql_query($queryDates, $db) or die(mysql_error());
  14. while($row=mysql_fetch_assoc($q))
  15. {
  16. $rows[]=$row;
  17. }
  18. return $rows;
  19. }
  20. //UNREG THE EMAIL AND ATTENDING
  21. function unReg($email, $class)
  22. {
  23. require('config.php');
  24. $db=mysql_connect($h, $u, $p);
  25. mysql_select_db($d, $db);
  26.  
  27. $queryDates="DELETE * FROM scheduled WHERE email='".$email."' AND event_id='".$class."';
  28. $q=mysql_query($queryDates, $db) or die(mysql_error());
  29.  
  30. }
  31.  
  32. function addCount($event_id, $count)
  33. {
  34. require('config.php');
  35. $db=mysql_connect($h, $u, $p);
  36. mysql_select_db($d, $db);
  37.  
  38. $queryDates="UPDATE events SET attending='".$count."'event_id='".$email."'";
  39. $q=mysql_query($queryDates, $db) or die(mysql_error());
  40. }
  41. function seatsAvailable($event)
  42. {
  43.  
  44. require('config.php');
  45. $db=mysql_connect($h, $u, $p);
  46. mysql_select_db($d, $db);
  47.  
  48. $queryDates="SELECT * FROM events WHERE event_id='".$event."'";
  49. $q=mysql_query($queryDates, $db) or die(mysql_error());
  50.  
  51. while($row=mysql_fetch_assoc($q))
  52. {
  53. $count=$seatLimit+$row['attending'];
  54. }
  55.  
  56. $_SESSION['count']=$count;
  57. }
  58.  
  59.  
  60. function getEvents($cat)
  61. {
  62. require('config.php');
  63. $db=mysql_connect($h, $u, $p);
  64. mysql_select_db($d, $db);
  65.  
  66. //CHECK ALL EVENT IDS AGAINST EVENTS TABLE IN DATES TABLE
  67.  
  68. $events="SELECT * FROM events WHERE category_id='".$cat."'";
  69. $rowEvents=mysql_query($events, $db) or die(mysql_error());
  70.  
  71.  
  72. //FIND SELECTED COURSE DATE
  73.  
  74. //SET DATE FORMAT
  75. $date=date("Y-m-d G:i:s");
  76.  
  77. while ($eventId=mysql_fetch_array($rowEvents))
  78. {
  79. //GET ALL IDS FOR EVENTS WITHIN CAT
  80. $eventIds[]=$eventId['event_id'];
  81. }
  82.  
  83. //GET EVENT IDS FOR EVENTS SEARCH
  84. $got=array();
  85. foreach ($eventIds as $event)
  86. {
  87.  
  88. $queryDates="SELECT * FROM dates WHERE date>='".$date."' AND event_id='".$event."' ORDER BY date";
  89.  
  90. $rowDates=mysql_query($queryDates, $db) or die(mysql_error());
  91.  
  92. $got=mysql_fetch_assoc($rowDates);
  93.  
  94. $gotId[$got['event_id']] = $got;
  95.  
  96.  
  97.  
  98.  
  99.  
  100. }
  101.  
  102.  
  103.  
  104. foreach($gotId as $id => $got)
  105. {
  106.  
  107. if ($id)
  108. {
  109.  
  110. $queryDates="SELECT * FROM events WHERE event_id='".$id."'";
  111. $q=mysql_query($queryDates, $db) or die(mysql_error());
  112.  
  113. while($row=mysql_fetch_assoc($q))
  114. {
  115. $seatLimit=10;
  116. $seatsLeft=$seatLimit-$row['attending'];
  117.  
  118. echo "<option value=".$got['event_id'].">".$row['title']."-:".$got['date']."-:(LEFT:".$seatsLeft.")</option><BR>";
  119.  
  120. }
  121. $_SESSION['description']=$row['description'];
  122.  
  123. }
  124.  
  125. }
  126. return $row['date'];
  127. }
  128.  
  129. function getDateById($eventId)
  130. {
  131.  
  132. require('config.php');
  133. $db=mysql_connect($h, $u, $p);
  134. mysql_select_db($d, $db);
  135.  
  136. $queryDates="SELECT date FROM dates WHERE event_id='".$eventId."'";
  137. $q=mysql_query($queryDates, $db) or die(mysql_error());
  138.  
  139. while ($event=mysql_fetch_assoc($q))
  140. {
  141. $formated=strtotime($event['date']);
  142. return date("m/d/y g:ia", $formated);
  143. }
  144.  
  145.  
  146. }
  147. function getEventById($eventId)
  148. {
  149.  
  150. require('config.php');
  151. $db=mysql_connect($h, $u, $p);
  152. mysql_select_db($d, $db);
  153.  
  154. $queryDates="SELECT title FROM events WHERE event_id='".$eventId."'";
  155. $q=mysql_query($queryDates, $db) or die(mysql_error());
  156.  
  157. while ($event=mysql_fetch_assoc($q))
  158. {
  159. $event=$event['title'];
  160. return $event;
  161. }
  162. }
  163.  
  164. function checkReqEntry($entry)
  165. {
  166.  
  167. if(!$_POST[$entry])
  168. {
  169. return true;
  170. }
  171. else
  172. {
  173. echo $entry." HAS NOT BEEN SET";
  174. return false;
  175. }
  176. }
  177. ?>
Add Comment
Please, Sign In to add comment