470,641 Members | 2,453 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

How to show the available time on the day which i select??

52
Hi ,
I stuck in my project as i face a problem
How to show the available time of the venue when i select the day??
Need to connect to the database to find out the available time of the venue on that day i select???


The selection the day
Expand|Select|Wrap|Line Numbers
  1. ?>
  2. <select name="p_day" id="p_day">
  3.   <option <?php if(isset($_COOKIE['Day']) && $_COOKIE['Day']=="Monday") echo "selected"; ?> value="Monday">Monday</option>
  4.   <option <?php if(isset($_COOKIE['Day']) && $_COOKIE['Day']=="Tuesday") echo "selected"; ?> value="Tuesday">Tuesday</option>
  5.   <option <?php if(isset($_COOKIE['Day']) && $_COOKIE['Day']=="Wednesday") echo "selected"; ?> value="Wednesday">Wednesday</option>
  6.   <option <?php if(isset($_COOKIE['Day']) && $_COOKIE['Day']=="Thursday") echo "selected"; ?> value="Thursday">Thursday</option>
  7.   <option <?php if(isset($_COOKIE['Day']) && $_COOKIE['Day']=="Friday") echo "selected"; ?> value="Friday">Friday</option>
  8.   <option <?php if(isset($_COOKIE['Day']) && $_COOKIE['Day']=="Saturday") echo "selected"; ?> value="Saturday">Saturday</option>
  9. </select>
  10.  
This is the selection of the time which i think need to change all the code here!

Expand|Select|Wrap|Line Numbers
  1. ?>
  2. <select name="p_time" id="select7">
  3.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="0800") echo "selected"; ?> value="0800">0800</option>
  4.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="0900") echo "selected"; ?> value="0900">0900</option>
  5.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1010") echo "selected"; ?> value="1010">1010</option>
  6.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1110") echo "selected"; ?> value="1110">1110</option>
  7.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1205") echo "selected"; ?> value="1205">1205</option>
  8.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1300") echo "selected"; ?> value="1300">1300</option>
  9.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1400") echo "selected"; ?> value="1400">1400</option>
  10.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1510") echo "selected"; ?> value="1510">1510</option>
  11.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1610") echo "selected"; ?> value="1610">1610</option>
  12.   <option <?php if(isset($_COOKIE['Time']) && $_COOKIE['Time']=="1710") echo "selected"; ?> value="1710">1710</option>
  13. </select>
  14.  

This is the selection of the venue
Expand|Select|Wrap|Line Numbers
  1. ?>
  2. <select name="p_venue">
  3. <?php
  4. do {  
  5. ?>
  6.   <option 
  7.   <?php if(isset($_COOKIE['Venue']) && $_COOKIE['Venue']==$row_VenueRS['venue']) echo "selected"; ?>
  8.     value="<?php echo $row_VenueRS['venue']?>"><?php echo $row_VenueRS['venue']?>
  9.   </option>
  10. <?php
  11. } while ($row_VenueRS = mysql_fetch_assoc($VenueRS));
  12.   $rows = mysql_num_rows($VenueRS);
  13.   if($rows > 0) {
  14.   mysql_data_seek($VenueRS, 0);
  15.   $row_VenueRS = mysql_fetch_assoc($VenueRS);
  16. }
  17. ?>
  18. </select>
  19.  
Jun 27 '07 #1
5 1636
chaos
52
As i doing timetable system whereby ppl can book the venue and it will update the system



this code might help u all understand how i check the check button work
[PHP]<input type="button" name="Button" value="Check" onClick="checkfacility(change_timetable.p_time.val ue,change_timetable.p_day.value,change_timetable.p _venue.value,change_timetable.p_duration.value,'us er')">[/PHP]

This is checkfacility.php
Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <?php $day= $_GET['day']; ?>
  3. <?php $duration= $_GET['duration']; ?>
  4. <?php $venue= $_GET['venue']; ?>
  5. <?php $time= $_GET['time']; ?>
  6. <?php $rights= $_GET['rights']; ?>
  7.  
  8. <?php     setcookie("Venue",$venue);
  9.     setcookie("Day",$day);
  10.     setcookie("Time",$time);
  11.     setcookie("Duration",$duration);
  12. ?>
  13.  
  14. <?php
  15.  
  16. switch($time)
  17. {
  18.     case '0800': $hourset = 0; break;
  19.     case '0900': $hourset = 1; break;
  20.     case '1010': $hourset = 2; break;
  21.     case '1110': $hourset = 3; break;
  22.     case '1205': $hourset = 4; break;
  23.     case '1300': $hourset = 5; break;
  24.     case '1400': $hourset = 6; break;
  25.     case '1510': $hourset = 7; break;
  26.     case '1610': $hourset = 8; break;
  27.     case '1710': $hourset = 9; break;
  28. }
  29.  
  30. switch($day)
  31. {
  32.     case 'Monday':        //timeslot is from 0 to 9
  33.                         switch($hourset)
  34.                         {
  35.                             case 0:    $slot=0; break;
  36.                             case 1: $slot=1; break;
  37.                             case 2: $slot=2; break;
  38.                             case 3: $slot=3; break;
  39.                             case 4: $slot=4; break;
  40.                             case 5: $slot=5; break;
  41.                             case 6: $slot=6; break;
  42.                             case 7: $slot=7; break;
  43.                             case 8: $slot=8; break;
  44.                             case 9: $slot=9; break;
  45.                         }
  46.                         break;
  47.  
  48.     case 'Tuesday':        //time slot is from 10-19
  49.                         switch($hourset)
  50.                         {
  51.                             case 0:    $slot=10; break;
  52.                             case 1: $slot=11; break;
  53.                             case 2: $slot=12; break;
  54.                             case 3: $slot=13; break;
  55.                             case 4: $slot=14; break;
  56.                             case 5: $slot=15; break;
  57.                             case 6: $slot=16; break;
  58.                             case 7: $slot=17; break;
  59.                             case 8: $slot=18; break;
  60.                             case 9: $slot=19; break;
  61.                         }
  62.                         break;
  63.  
  64.     case 'Wednesday':    //time slot is from 20-29
  65.                         switch($hourset)
  66.                         {
  67.                             case 0:    $slot=20; break;
  68.                             case 1: $slot=21; break;
  69.                             case 2: $slot=22; break;
  70.                             case 3: $slot=23; break;
  71.                             case 4: $slot=24; break;
  72.                             case 5: $slot=25; break;
  73.                             case 6: $slot=26; break;
  74.                             case 7: $slot=27; break;
  75.                             case 8: $slot=28; break;
  76.                             case 9: $slot=29; break;
  77.                         }
  78.                         break;    
  79.  
  80.     case 'Thursday':    // time slot is 30-39
  81.                         switch($hourset)
  82.                         {
  83.                             case 0:    $slot=30; break;
  84.                             case 1: $slot=31; break;
  85.                             case 2: $slot=32; break;
  86.                             case 3: $slot=33; break;
  87.                             case 4: $slot=34; break;
  88.                             case 5: $slot=35; break;
  89.                             case 6: $slot=36; break;
  90.                             case 7: $slot=37; break;
  91.                             case 8: $slot=38; break;
  92.                             case 9: $slot=39; break;
  93.                         }
  94.                         break;
  95.  
  96.     case 'Friday':        // time slot is 40-49
  97.                         switch($hourset)
  98.                         {
  99.                             case 0:    $slot=40; break;
  100.                             case 1: $slot=41; break;
  101.                             case 2: $slot=42; break;
  102.                             case 3: $slot=43; break;
  103.                             case 4: $slot=44; break;
  104.                             case 5: $slot=45; break;
  105.                             case 6: $slot=46; break;
  106.                             case 7: $slot=47; break;
  107.                             case 8: $slot=48; break;
  108.                             case 9: $slot=49; break;
  109.                         }
  110.                         break;
  111.  
  112.     case 'Saturday':    // time slot is 50-54
  113.                         switch($hourset)
  114.                         {
  115.                             case 0:    $slot=50; break;
  116.                             case 1: $slot=51; break;
  117.                             case 2: $slot=52; break;
  118.                             case 3: $slot=53; break;
  119.                             case 4: $slot=54; break;
  120.                             case 5: $slot=55; break;
  121.                             case 6: $slot=56; break;
  122.                             case 7: $slot=57; break;
  123.                             case 8: $slot=58; break;
  124.                             case 9: $slot=59; break;
  125.                         }
  126.                         break;
  127. }
  128. ?>
  129.  
  130. <?php
  131. echo $time;
  132. echo "<BR>Time slot is ".$slot."<BR>";
  133.  
  134. mysql_select_db($database_conn, $conn);
  135. $query_Recordset2 = "SELECT * FROM facilities WHERE venue='$venue'";
  136. $Recordset2 = mysql_query($query_Recordset2, $conn) or die(mysql_error());
  137. $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  138. $totalRows_Recordset2 = mysql_num_rows($Recordset2);
  139.  
  140. $query_RS3 = "SELECT * FROM staff WHERE staff_1 ='".$_SESSION['MM_Username']."'";
  141. echo $query_RS3;
  142. $RS3 = mysql_query($query_RS3, $conn) or die(mysql_error());
  143. $row_RS3= mysql_fetch_assoc($RS3);
  144. $totalRows_RS3 = mysql_num_rows($RS3);
  145.  
  146.  
  147. $canBook=true;
  148.  
  149. for($i=0;$i<$duration;$i++)
  150. {
  151. $facilityAvailable =$row_Recordset2["_".($slot+$i)];
  152. echo "_".($slot+$i)."=".$facilityAvailable."<BR>";
  153.  
  154. if($facilityAvailable!=0)
  155.     $canBook=false;
  156.     for($i=0;$i<$duration;$i++)
  157.     {
  158.         $ModuleAtProposedSlot=$row_RS3["_".($slot+$i)];
  159.  
  160.         if($ModuleAtProposedSlot!=0)
  161.             $canBook=false;
  162.     }
  163. }
  164.  
  165.     if($canBook)
  166.     {
  167.         if ($rights =="admin")
  168.         {
  169.             echo "<script>alert('Change Request OK. Proceed to Approve')
  170.         window.opener.location=window.opener.location+'&&showSubmit=true'
  171.             </script>";
  172.         }
  173.         else
  174.         {
  175.             echo "<script>alert('Available for booking')
  176.         window.opener.location=window.opener.location+'&&showSubmit=true'
  177.             </script>";
  178.         }    
  179.     }
  180.     else
  181.     {    
  182.         if ($rights =="admin")
  183.         {    
  184.             echo "<script>alert('Facility not available!')
  185.                 window.opener.location=window.opener.location+'&&showSubmit=false'
  186.             </script>";
  187.         }
  188.  
  189.         else
  190.         {    
  191.             echo "<script>alert('This timeslot is not available!')
  192.                 window.opener.location=window.opener.location+'&&showSubmit=false'
  193.             </script>";
  194.         }
  195.  
  196.         unset($_COOKIE['Venue']);
  197.     }
  198.     echo "<script>window.close()</script>";
  199. ?>
[Please use CODE tags when posting source code. Thanks! --pbmods]
Jun 27 '07 #2
chaos
52
Someone Pls Help Me
THX
Jun 28 '07 #3
chaos
52
anyone know how to solve the problem
Jun 29 '07 #4
chaos
52
Help Help Help !!!
Anyone Pls Help Me!
Jul 1 '07 #5
kovik
1,044 Expert 1GB
No one will help you because:

1) You haven't asked much of a question other than "help me!"
2) You aren't even trying... I help those who help themselves.
3) You've posted too much code. No one wants to read it all, and most of it doesn't matter.
4) You're spamming the board with bumps.

Here's what you need to do:

1) Think logically about the problem.
2) Don't expect PHP to be magic.
3) Find out *exactly* where the problem is occurring
4) THEN ask questions.

Now, please stop spamming. I haven't read your code because it's obvious that you're hardly trying... Just looking for hand-outs.
Jul 1 '07 #6

Post your reply

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

Similar topics

4 posts views Thread by Jens Riedel | last post: by
44 posts views Thread by Mariusz Jedrzejewski | last post: by
3 posts views Thread by Bryan Harrington | last post: by
20 posts views Thread by WindAndWaves | last post: by
5 posts views Thread by psvhans | last post: by
20 posts views Thread by ed | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.