I have the following code which takes a single date and creates availability table for a date in a databse but I need it to have a start and and end date to work. Can anybody help my code is below and I am a complete novice and not a programmer at all.
This works a dream on one date.
<HTML>
<HEAD>
<TITLE>Retrieving Data from Availability Table</TITLE>
</HEAD>
<BODY>
<?php
// Set the variables for the database access:
$Host = "localhost";
$User = "admin";
$Password = "admin";
$DBName = "BookSys";
$TableName = "BookTab";
$TableName2 = "AvailTab";
$Link = mysql_connect ($Host, $User, $Password);
$Query = "SELECT * from $TableName2 where (ArrivDate='$SearchSDate')";
$Result = mysql_db_query ($DBName, $Query, $Link);
// Create a table.
print ("<TABLE BORDER=1 WIDTH=\"75%\" CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>\n");
print ("<TR ALIGN=CENTER VALIGN=TOP>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>Arrival Date</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>Free Singles</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>Free Doubles</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>Free Family</TD>\n");
print ("</TR>\n");
// Fetch the results from the database.
while ($Row = mysql_fetch_array ($Result)) {
$Arriv = $Row[ArrivDate];
$Single = $Single + $Row[OneBed];
$Double = $Double + $Row[TwoBed];
$Family = $Family + $Row[Family];
}
mysql_close ($Link);
//Take the booked rooms from my available rooms
$Single = 2 - $Single;
$Double = 7 - $Double;
$Family = 1 - $Family;
//Fully Booked test
If ($Single <= 0) {
$Single = "Fully Booked";
}
If ($Double <= 0) {
$Single = "Fully Booked";
}
If ($Family <= 0) {
$Family = "Fully Booked";
}
//Print results
print ("<TR ALIGN=CENTER VALIGN=TOP>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$Arriv</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$Single</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$Double</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$Family</TD>\n");
print ("</TR>\n");
//Link back to main menu
print ("<BR><Center><A HREF=\"mainmenu.html\">Return to Main Menu</A></Center><BR>\n");
?>
</BODY>
</HTML>