almystersv Posted February 27, 2008 Share Posted February 27, 2008 Hi Guys, I have this page that allows the users to book meeting rooms. I have the form on the left of the page that allows the user to select, a room, date and time. On the right is a table that displays all the bookings that have been made. What I would like is for the table on the right to populate with all the bookings made, but once a date is selected my the user I want the table to populate with bookings for that date. I am unsure how to approach this and any help would be greatly appreciated. Here is the code for the meeting room booking page. Quote Link to comment Share on other sites More sharing options...
bpops Posted February 27, 2008 Share Posted February 27, 2008 Waiting to see your code, but what you'll need to do is to perform your mySQL query (I'm assuming you're using mysql?) with a condition on date, such as $date = "2008-02-27"; $query = "SELECT * FROM bookings WHERE DATE = '$date'"; $result = mysql_query($query); Quote Link to comment Share on other sites More sharing options...
almystersv Posted February 27, 2008 Author Share Posted February 27, 2008 hi, i have been trying for ages to post my code but for some reason it doesn't like it! Im getting a http 406 error.!?!? I am using MySQL. This is my current SQL "SELECT * FROM booking b, employee e WHERE e.empID = b.empID LIMIT $offset, $limit" I am using a javascript calendar ($bkgDate) and would like the table to populate with the date that when it has been selected. Quote Link to comment Share on other sites More sharing options...
revraz Posted February 27, 2008 Share Posted February 27, 2008 http://www.phpfreaks.com/forums/index.php/topic,96050.0.html Quote Link to comment Share on other sites More sharing options...
almystersv Posted February 27, 2008 Author Share Posted February 27, 2008 <?php session_start(); if (isset($_SESSION['username']) == false){ header("Location: login.php"); exit(); } require "connect.php"; $limit = 10; $query_count = "SELECT count(*) FROM booking"; $result_count = mysql_query($query_count) or die("Error: " . mysql_error()); $totalrows = mysql_result($result_count, 0, 0); $numofpages = ceil($totalrows/$limit); if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; $offset = ($page - 1) * $limit; $orderby = $_GET['var']; if (($_GET['text'] == "") || ($_GET['field'] == "*")) { $query = "SELECT * FROM booking b, employee e WHERE e.empID = b.empID LIMIT $offset, $limit"; } else { $query = "SELECT * FROM booking b, employee e WHERE e.empID = b.empID AND ".$_GET['field']." like '%".$_GET['text']."%' order by bookingID"; } $result = mysql_query($query, $connection) or die ("Error: " . mysql_error()); ?> <!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <html> <title>BIS Portal</title> <link rel="stylesheet" type="text/css" href="mystylelogin.css" /> <head> </head> <body> <div id="header">Book a Meeting Room</div> <div id="BookingSearch"> <form method="get" action="MeetingMain.php" name="search"> <table width="100%" border="0"> <tr> <td width="17%">Search Booking :</td> <td width="21%"><input name="text" type="text" id="text" /></td> <td width="2%"> </td> <td width="21%">Select fields to search:</td> <td width="27%"><select name="field" id="field"> <option value="*">Choose category</option> <option value="bookingID">Booking ID</option> <option value="roomID">Room</option> <option value="username">User</option> <option value="bkgDate">Date</option> <option value="bkgTime">Time</option> </select></td> <td width="2%"> </td> <td width="16%"><div align="center"> <input name="search" type="submit" id="search" value="Search" /> </div></td> </tr> </table> </form> </div> <div id="MeetingTable"> <form action="MeetingQuery.php" method="post"> <table width="101%" border="0"> <hr /> <tr> <td width="39%">Select a building:</td> <td width="61%"><select name="building"> <option >[select a Building]</option> <option >North</option> <option >South</option> </select></td> </tr> <tr> <td> </td> <td><span class="style1"> <?php if(isset($_GET['message1'])) { echo $_GET['message1']; } ?> </span></td> </tr> <tr> <td>Select a Meeting Room: </td> <td><select name="roomID"> <option >[select Meeting Room Number]</option> <option >020</option> <option >021</option> <option >105</option> <option >106</option> <option >113</option> <option >215</option> <option >216</option> </select></td> </tr> <tr> <td> </td> <td><span class="style1"> <?php if(isset($_GET['message2'])) { echo $_GET['message2']; } ?> </span></td> </tr> <tr> <td>Select a Date: </td> <td><p><>DateInput('bkgDate', true, 'YYYY-MM-DD')</></p></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Select a Time: </td> <td><select name="bkgTime"> <option >[select Meeting Time]</option> <option >0900-1000</option> <option >1000-1100</option> <option >1100-1200</option> <option >1200-1300</option> <option >1300-1400</option> <option >1400-1500</option> <option >1500-1600</option> <option >1600-1700</option> </select></td> </tr> <tr> <td> </td> <td><span class="style1"> <?php if(isset($_GET['message3'])) { echo $_GET['message3']; } ?> </span></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input name="empID" value="<?php echo $_SESSION['empID']?>" size="3" type="hidden" /> </td> <td><div align="left"><input name="Save" type="submit" value="Submit Meeting Room" class="btn" /></div></td> </tr> </table> </form> <table width="100%" border="0"> <tr> <td><div align="center"><span class="style1"> <?php if (isset($_GET['message4'])) { echo $_GET['message4']; } ?></span></div></td> </tr> </table> <div id="BookingsTable"> <table width="100%" border="0"> <hr /> <tr> <th><a href="MeetingMain.php?var=bookingID">Booking ID</a></th> <th><a href="MeetingMain.php?var=roomID">Room</a></th> <th><a href="MeetingMain.php?var=bkgDate">Date</a></th> <th><a href="MeetingMain.php?var=bkgTime">Time</a></th> <th><a href="MeetingMain.php?var=username">User</a></th> <?php while($row = mysql_fetch_array($result)) { echo("<tr>\n<td align='center'>"); echo($row["bookingID"]); echo("</td>\n<td>"); echo($row["roomID"]); echo("</td>\n<td>"); echo($row["bkgDate"]); echo("</td>\n<td>"); echo($row["bkgTime"]); echo("</td>\n<td>"); echo($row["username"]); echo("</td>\n</tr>"); } echo("</table>"); //Enables the PREV link if not first page if ($page > 1) { echo("<a href=\"MeetingMain.php?var=bookingID&page=".($page-1)."\">PREV</a> "); } else { echo("PREV "); } //Creates the links for each page for ($i=1; $i<=$numofpages; $i++) { if ($i == $page) { echo "$i "; } else { echo "<a href=\"MeetingMain.php?var=bookingID&page=$i\">$i</a> "; } } //Enable the Next link if not last page if ($page < $numofpages) { echo("<a href=\"MeetingMain.php?var=bookingID&page=".($page+1)."\">NEXT</a>"); } else { echo("NEXT"); } ?> <tr> </table> </div> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
almystersv Posted February 27, 2008 Author Share Posted February 27, 2008 Had to remove the java script that was in there.. ie. the calendar i am using type="text/javascript" src="calendarDateInput.js" DateInput('bkgDate', true, 'YYYY-MM-DD') Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.