php - My time slots are not booked -


i want create basic time slot booking system. i've run problems.

i have created calendar can see happening on speific date:

calendar

it takes information database table. i'm using phpmyadmin, , i've added date manually in there.

database

as can see in table, use start time , endtime.

if click date in calendar, create add-event link this:

<?php if (isset ( $_get ['v'] )) {     echo "<a href='test.php . ?month=" . $month . "&day=" . $day . "&year=" . $year . "&v=true&f=true'>add event</a>";     if (isset ( $_get ['f'] )) {         include ("test.php");     }     $sqlevent = "select * calendar eventdate='" . $month . "/" . $day . "/" . $year . "'";     $resultevents = mysqli_query ( $mysqli1, $sqlevent );     echo "<br>";     while ( $events = mysqli_fetch_array ( $resultevents ) ) {           } } ?> 

clicking makes url somehting this: test.php%20.%20?month=04&day=18&year=2014&v=true&f=true#

i've included whole test.php file:

<?php  $hostname = 'localhost'; $username = 'root'; $password = ''; $dbname = "calendar";  $error = 'cannot connect database';  $mysqli1 = new mysqli ( $hostname, $username, $password, $dbname ) or die ( $error );  if (isset ( $_get ['day'] )) {     $day = $_get ['day']; } else {     $day = date ( "j" ); }  if (isset ( $_get ['month'] )) {     $month = $_get ['month']; } else {     $month = date ( "n" ); }  if (isset ( $_get ['year'] )) {     $year = $_get ['year']; } else {     $year = date ( "y" ); }  $datetocompare = $month . '/' . $day . '/' . $year;      echo "<br/><br/><h3>reservations</h3>";     $timearray =  array(8,9,10,11,12,13,14,15,16,17,18,19,20,21,22);     $tablecolor = 1;     echo "<table style='width: 90%;'>";     echo "<tr>";         echo "<th>";             echo "time";         echo "</th>";         echo "<th>";             echo "status";         echo "</th>";      echo "</tr>";     foreach ($timearray $timearrays) {         if($tablecolor %2 == 0) {             echo "<tr>";         }         else {             echo "<tr style='background-color: rgb(0,100,255); background: rgb(0,100,255);'>";         }              echo "<th>";             if ($timearrays == 8) {echo "<h3>8-9am</h3>";}             if ($timearrays == 9) {echo "<h3>9-10am</h3>";}             if ($timearrays == 10) {echo "<h3>10-11am</h3>";}             if ($timearrays == 11) {echo "<h3>11-12am</h3>";}             if ($timearrays == 12) {echo "<h3>12-13am</h3>";}             if ($timearrays == 13) {echo "<h3>13-14am</h3>";}             //develop timeslots here display required             echo "</th>";             echo "<td>";              $sql = "select * calendar eventdate='" . $datetocompare . "'and timestart >= $timearrays , endtime <= $timearrays;";              $result = mysqli_query($mysqli1,$sql);              if (mysqli_num_rows($result) == 0) {                 echo "<a href='#'><h3 style='color: rgb(255,0,0);'>reserve</h3></a>";             } else {                 echo "<h3>not available, taken someone</h3>";                 while($row = mysql_fetch_array($result)) {                     echo "<br />";                 }             }             echo "</td>";         echo "</tr>";         $tablecolor++;     }     echo "</table>";  ?> 

as can see, try display timeslots: $sql = "select * calendar eventdate='" . $datetocompare . "'and timestart >= $timearrays , endtime <= $timearrays;";

i think dates correctly url, don't see reservations given date.

enter image description here

i hope of can me out. , please ask, if need provide more of code.

or if has better idea on how this, please share.

i'm not sure if should conserned time. want ability click on "reserve" , reverse specific time slot. maybe start , end time isn't nessary?

try debug application. guess problem $timearrays in query create. don't think (haven't tested) works way.

my suggestion, print out $sql after you've initialized , see returns. open phpmyadmin (which guess you're using, looks of data) , see returns there.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -