Jump to content

Booking system help


almystersv

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/93397-booking-system-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/93397-booking-system-help/#findComment-478501
Share on other sites

<?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>

Link to comment
https://forums.phpfreaks.com/topic/93397-booking-system-help/#findComment-478510
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.