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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chaos
    New Member
    • Jun 2007
    • 52

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

    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
    [code=php]
    ?>
    <select name="p_day" id="p_day">
    <option <?php if(isset($_COOK IE['Day']) && $_COOKIE['Day']=="Monday") echo "selected"; ?> value="Monday"> Monday</option>
    <option <?php if(isset($_COOK IE['Day']) && $_COOKIE['Day']=="Tuesday") echo "selected"; ?> value="Tuesday" >Tuesday</option>
    <option <?php if(isset($_COOK IE['Day']) && $_COOKIE['Day']=="Wednesday" ) echo "selected"; ?> value="Wednesda y">Wednesday </option>
    <option <?php if(isset($_COOK IE['Day']) && $_COOKIE['Day']=="Thursday") echo "selected"; ?> value="Thursday ">Thursday</option>
    <option <?php if(isset($_COOK IE['Day']) && $_COOKIE['Day']=="Friday") echo "selected"; ?> value="Friday"> Friday</option>
    <option <?php if(isset($_COOK IE['Day']) && $_COOKIE['Day']=="Saturday") echo "selected"; ?> value="Saturday ">Saturday</option>
    </select>
    [/code]

    This is the selection of the time which i think need to change all the code here!

    [code=php]
    ?>
    <select name="p_time" id="select7">
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="0800") echo "selected"; ?> value="0800">08 00</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="0900") echo "selected"; ?> value="0900">09 00</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1010") echo "selected"; ?> value="1010">10 10</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1110") echo "selected"; ?> value="1110">11 10</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1205") echo "selected"; ?> value="1205">12 05</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1300") echo "selected"; ?> value="1300">13 00</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1400") echo "selected"; ?> value="1400">14 00</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1510") echo "selected"; ?> value="1510">15 10</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1610") echo "selected"; ?> value="1610">16 10</option>
    <option <?php if(isset($_COOK IE['Time']) && $_COOKIE['Time']=="1710") echo "selected"; ?> value="1710">17 10</option>
    </select>
    [/code]


    This is the selection of the venue
    [code=php]
    ?>
    <select name="p_venue">
    <?php
    do {
    ?>
    <option
    <?php if(isset($_COOK IE['Venue']) && $_COOKIE['Venue']==$row_VenueRS['venue']) echo "selected"; ?>
    value="<?php echo $row_VenueRS['venue']?>"><?php echo $row_VenueRS['venue']?>
    </option>
    <?php
    } while ($row_VenueRS = mysql_fetch_ass oc($VenueRS));
    $rows = mysql_num_rows( $VenueRS);
    if($rows > 0) {
    mysql_data_seek ($VenueRS, 0);
    $row_VenueRS = mysql_fetch_ass oc($VenueRS);
    }
    ?>
    </select>
    [/code]
    Last edited by Atli; Jun 27 '07, 01:13 PM. Reason: Added code tags and made more readable.
  • chaos
    New Member
    • Jun 2007
    • 52

    #2
    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="checkf acility(change_ timetable.p_tim e.value,change_ timetable.p_day .value,change_t imetable.p_venu e.value,change_ timetable.p_dur ation.value,'us er')">[/PHP]

    This is checkfacility.p hp
    [code=php]
    <body>
    <?php $day= $_GET['day']; ?>
    <?php $duration= $_GET['duration']; ?>
    <?php $venue= $_GET['venue']; ?>
    <?php $time= $_GET['time']; ?>
    <?php $rights= $_GET['rights']; ?>

    <?php setcookie("Venu e",$venue);
    setcookie("Day" ,$day);
    setcookie("Time ",$time);
    setcookie("Dura tion",$duration );
    ?>

    <?php

    switch($time)
    {
    case '0800': $hourset = 0; break;
    case '0900': $hourset = 1; break;
    case '1010': $hourset = 2; break;
    case '1110': $hourset = 3; break;
    case '1205': $hourset = 4; break;
    case '1300': $hourset = 5; break;
    case '1400': $hourset = 6; break;
    case '1510': $hourset = 7; break;
    case '1610': $hourset = 8; break;
    case '1710': $hourset = 9; break;
    }

    switch($day)
    {
    case 'Monday': //timeslot is from 0 to 9
    switch($hourset )
    {
    case 0: $slot=0; break;
    case 1: $slot=1; break;
    case 2: $slot=2; break;
    case 3: $slot=3; break;
    case 4: $slot=4; break;
    case 5: $slot=5; break;
    case 6: $slot=6; break;
    case 7: $slot=7; break;
    case 8: $slot=8; break;
    case 9: $slot=9; break;
    }
    break;

    case 'Tuesday': //time slot is from 10-19
    switch($hourset )
    {
    case 0: $slot=10; break;
    case 1: $slot=11; break;
    case 2: $slot=12; break;
    case 3: $slot=13; break;
    case 4: $slot=14; break;
    case 5: $slot=15; break;
    case 6: $slot=16; break;
    case 7: $slot=17; break;
    case 8: $slot=18; break;
    case 9: $slot=19; break;
    }
    break;

    case 'Wednesday': //time slot is from 20-29
    switch($hourset )
    {
    case 0: $slot=20; break;
    case 1: $slot=21; break;
    case 2: $slot=22; break;
    case 3: $slot=23; break;
    case 4: $slot=24; break;
    case 5: $slot=25; break;
    case 6: $slot=26; break;
    case 7: $slot=27; break;
    case 8: $slot=28; break;
    case 9: $slot=29; break;
    }
    break;

    case 'Thursday': // time slot is 30-39
    switch($hourset )
    {
    case 0: $slot=30; break;
    case 1: $slot=31; break;
    case 2: $slot=32; break;
    case 3: $slot=33; break;
    case 4: $slot=34; break;
    case 5: $slot=35; break;
    case 6: $slot=36; break;
    case 7: $slot=37; break;
    case 8: $slot=38; break;
    case 9: $slot=39; break;
    }
    break;

    case 'Friday': // time slot is 40-49
    switch($hourset )
    {
    case 0: $slot=40; break;
    case 1: $slot=41; break;
    case 2: $slot=42; break;
    case 3: $slot=43; break;
    case 4: $slot=44; break;
    case 5: $slot=45; break;
    case 6: $slot=46; break;
    case 7: $slot=47; break;
    case 8: $slot=48; break;
    case 9: $slot=49; break;
    }
    break;

    case 'Saturday': // time slot is 50-54
    switch($hourset )
    {
    case 0: $slot=50; break;
    case 1: $slot=51; break;
    case 2: $slot=52; break;
    case 3: $slot=53; break;
    case 4: $slot=54; break;
    case 5: $slot=55; break;
    case 6: $slot=56; break;
    case 7: $slot=57; break;
    case 8: $slot=58; break;
    case 9: $slot=59; break;
    }
    break;
    }
    ?>

    <?php
    echo $time;
    echo "<BR>Time slot is ".$slot."<B R>";

    mysql_select_db ($database_conn , $conn);
    $query_Recordse t2 = "SELECT * FROM facilities WHERE venue='$venue'" ;
    $Recordset2 = mysql_query($qu ery_Recordset2, $conn) or die(mysql_error ());
    $row_Recordset2 = mysql_fetch_ass oc($Recordset2) ;
    $totalRows_Reco rdset2 = mysql_num_rows( $Recordset2);

    $query_RS3 = "SELECT * FROM staff WHERE staff_1 ='".$_SESSION['MM_Username']."'";
    echo $query_RS3;
    $RS3 = mysql_query($qu ery_RS3, $conn) or die(mysql_error ());
    $row_RS3= mysql_fetch_ass oc($RS3);
    $totalRows_RS3 = mysql_num_rows( $RS3);


    $canBook=true;

    for($i=0;$i<$du ration;$i++)
    {
    $facilityAvaila ble =$row_Recordset 2["_".($slot+ $i)];
    echo "_".($slot+$i). "=".$facilityAv ailable."<BR>";

    if($facilityAva ilable!=0)
    $canBook=false;
    for($i=0;$i<$du ration;$i++)
    {
    $ModuleAtPropos edSlot=$row_RS3["_".($slot+ $i)];

    if($ModuleAtPro posedSlot!=0)
    $canBook=false;
    }
    }

    if($canBook)
    {
    if ($rights =="admin")
    {
    echo "<script>alert( 'Change Request OK. Proceed to Approve')
    window.opener.l ocation=window. opener.location +'&&showSubmit= true'
    </script>";
    }
    else
    {
    echo "<script>alert( 'Available for booking')
    window.opener.l ocation=window. opener.location +'&&showSubmit= true'
    </script>";
    }
    }
    else
    {
    if ($rights =="admin")
    {
    echo "<script>alert( 'Facility not available!')
    window.opener.l ocation=window. opener.location +'&&showSubmit= false'
    </script>";
    }

    else
    {
    echo "<script>alert( 'This timeslot is not available!')
    window.opener.l ocation=window. opener.location +'&&showSubmit= false'
    </script>";
    }

    unset($_COOKIE['Venue']);
    }
    echo "<script>window .close()</script>";
    ?>[/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]

    Comment

    • chaos
      New Member
      • Jun 2007
      • 52

      #3
      Someone Pls Help Me
      THX

      Comment

      • chaos
        New Member
        • Jun 2007
        • 52

        #4
        anyone know how to solve the problem

        Comment

        • chaos
          New Member
          • Jun 2007
          • 52

          #5
          Help Help Help !!!
          Anyone Pls Help Me!

          Comment

          • kovik
            Recognized Expert Top Contributor
            • Jun 2007
            • 1044

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

            Comment

            Working...