Jump to content

Checking Availability Script


uniboy86

Recommended Posts

I am building a Letting and Maintenance managment system for my final year project. I have got a script to check avavailability and a table that displays the results but the loop I have displays the results before a query as been performed. And in a column in table it links to the booking script which is pointless having a check availability script if they can bypass.

 

Here is my code for the check availability page:

 

<?php

session_start();

if(isset($_SESSION['username']) ==  false){

header("Location: login.php");

exit();

}

$_SESSION['arrivaldate']=$_GET['arrivaldate'];

$_SESSION['departuredate']=$_GET['departuredate'];

require "connect.php";

$query = "SELECT RoomNo, Size, RentPerWeek FROM Room WHERE RoomNo NOT IN (SELECT RoomNo FROM Booking WHERE ArrivalDate < '".$_GET['departuredate']."' AND DepartureDate >'". $_GET['arrivaldate']."')";

 

$result = mysql_query($query, $connection)

or die("Unable to execute query<br>$query");

 

$query2 = "select * from dates";

$result2 = mysql_query($query2, $connection)

or die("Unable to execute query<br>$query2");

 

$query3 = "select * from dates";

$result3 = mysql_query($query3, $connection)

or die("Unable to execute query<br>$query3");

?>

<html>

<head>

<title></title>

<link rel="stylesheet" href="gf.css" type="text/css">

</head>

<body>

<div id="container">

<div id="logo">

<span>

<img src="logo.gif">

</span>

</div>

<div id="leftnavbar">

<div id="leftnavlist">

 

<ul>

<li><a href="index1.php">Main Menu</a></li>

</ul>

</div>

</div>

<div id="mainArea"><div id="centreArea">

<form method="get" action="checkavailabilityform.php" name="checkavailability">

<h1>Check Room Availability</h1>

<p><label for="size">Size:</label><input name="size" type="text"></p>

<p><label for="arrivaldate">Arrival Date:</label>

<select name="arrivaldate">

<?php

while($row=mysql_fetch_array($result2))

{?>

<option><?=$row['Date']?></option>

<?php }?>

</select>

 

<label for="departuredate">Departure Date:</label>

<select name="departuredate">

<?php

while($row=mysql_fetch_array($result3))

{ ?>

<option><?=$row['Date']?></option>

<?php } ?>

</select>

</p>

<p><input name="search" type="submit" id="search" value="Search"></p>

</form>

<table>

<?php

while($row=mysql_fetch_array($result))

{?>

<tr>

<td><?=$row['RoomNo']?></td>

<td><?=$row['Size']?></td>

<td><?=$row['RentPerWeek']?></td>

<td><a href="addroomtobooking.php?roomno=<?=$row['RoomNo']?>">Book</a></td>

</tr>

<?php

} ?>

</table>

</div>

</div>

<div id="footer">

<address></address>

</div>

</body>

</html>

 

Also how can i display results in muliple columns i have been told it is using a count but not too good at php to do this kind of logic

Link to comment
Share on other sites

Having read what I wrote I dont think I was  very clear what I wrote. Basically this is what I want to be able to do:

 

I display a page with the search facility on I use a search facility which the limits the results table to only the rooms available to book. I want to know how I stop the query being executed until I have searched for rooms available to be booked during a certain day. The code for this page is in the previous.

 

Can somebody please guide me in the right direction. I know it has something to do with an IF statement but I dont really know where to put it and what conditions I have to use.

 

Please Help

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.