Hi,
I am trying to create a php script that will query my database to produce a page showing when rooms are available, not in use and already reserved. The site is for a friend and little did I know the task I was undertaking. I am beginning to get a fair understanding of php and mysql but I think I lack many skills in order to get it all working. I have no other php people around me and this is becoming a real struggle. I have inserted the code below which should show you how I want the page to look. This was developed using some php software and I would really appreciate any assistance that anybody can help me with.. thanks..
I have placed the working code my website if you have the time to e-mail ne and help I will let you know where it is.
Wayne
<?php
//Include Common Files @1-5471E0F2
define("RelativePath", ".");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
//End Include Common Files
class clsGridroom { //room class @16-68EFE6DB
//Variables @16-9AD3C4FA
// Public variables
var $ComponentName;
var $Visible; var $Errors;
var $ds; var $PageSize;
var $SorterName = "";
var $SorterDirection = "";
var $PageNumber;
var $CCSEvents = "";
var $CCSEventResult;
// Grid Controls
var $StaticControls; var $RowControls;
//End Variables
//Class_Initialize Event @16-36D5E572
function clsGridroom()
{
global $FileName;
$this->ComponentName = "room";
$this->Visible = True;
$this->Errors = new clsErrors();
$this->ds = new clsroomDataSource();
$this->PageSize = CCGetParam($this->ComponentName . "PageSize", "");
if(!is_numeric($this->PageSize) || !strlen($this->PageSize))
$this->PageSize = 6;
else
$this->PageSize = intval($this->PageSize);
$this->PageNumber = intval(CCGetParam($this->ComponentName . "Page", 1));
$this->room_name = new clsControl(ccsLabel, "room_name", "room_name", ccsText, "", CCGetRequestParam("room_name", ccsGet));
}
//End Class_Initialize Event
//Initialize Method @16-383CA3E0
function Initialize()
{
if(!$this->Visible) return;
$this->ds->PageSize = $this->PageSize;
$this->ds->SetOrder($this->SorterName, $this->SorterDirection);
$this->ds->AbsolutePage = $this->PageNumber;
}
//End Initialize Method
//Show Method @16-76B1DA7B
function Show()
{
global $Tpl;
if(!$this->Visible) return;
$ShownRecords = 0;
$this->ds->Open();
$GridBlock = "Grid " . $this->ComponentName;
$Tpl->block_path = $GridBlock;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow");
$is_next_record = $this->ds->next_record();
if($is_next_record && $ShownRecords < $this->PageSize)
{
do {
$this->ds->SetValues();
$Tpl->block_path = $GridBlock . "/Row";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShowRow");
$Tpl->block_path = $GridBlock;
$Tpl->parse("Row", true);
$ShownRecords++;
$is_next_record = $this->ds->next_record();
} while ($is_next_record && $ShownRecords < $this->PageSize);
}
$this->room_name->SetValue($this->ds->room_name->GetValue());
$this->room_name->Show();
$Tpl->parse("", false);
$Tpl->block_path = "";
}
//End Show Method
} //End room Class @16-FCB6E20C
class clsroomDataSource extends clsDBdb38350525 { //roomDataSource Class @16-D756556C
//Variables @16-5DDFF4AC
var $CCSEvents = "";
var $CCSEventResult;
var $CountSQL;
var $wp;
// Datasource fields
var $room_name;
//End Variables
//Class_Initialize Event @16-05FE2A8E
function clsroomDataSource()
{
$this->Initialize();
$this->room_name = new clsField("room_name", ccsText, "");
}
//End Class_Initialize Event
//SetOrder Method @16-4C8FEA4C
function SetOrder($SorterName, $SorterDirection)
{
$this->Order = "room_name";
$this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection,
"");
}
//End SetOrder Method
//Prepare Method @16-DFF3DD87
function Prepare()
{
}
//End Prepare Method
//Open Method @16-790D224D
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect");
$this->CountSQL = "SELECT COUNT() " .
"FROM room";
$this->SQL = "SELECT " .
"FROM room";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect");
$this->RecordsCount = CCGetDBValue(CCBuildSQL($this->CountSQL, $this->Where, ""), $this);
$this->query(CCBuildSQL($this->SQL, $this->Where, $this->Order));
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect");
$this->MoveToPage($this->AbsolutePage);
}
//End Open Method
//SetValues Method @16-6C2C3DC0
function SetValues()
{
$this->room_name->SetDBValue($this->f("room_name"));
}
//End SetValues Method
} //End roomDataSource Class @16-FCB6E20C
//Initialize Page @1-895300B8
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
// Events;
$CCSEvents = "";
$CCSEventResult = "";
$FileName = "default.php";
$Redirect = "";
$TemplateFileName = "default.html";
$BlockToParse = "main";
$PathToRoot = "./";
//End Initialize Page
//Initialize Objects @1-D0A33726
$DBdb38350525 = new clsDBdb38350525();
// Controls
$Button2 = new clsButton("Button2");
$Go = new clsButton("Go");
$Button1 = new clsButton("Button1");
$room = new clsGridroom();
$room->Initialize();
$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize");
//End Initialize Objects
//Go to destination page @1-BEB91355
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
header("Location: " . $Redirect);
exit;
}
//End Go to destination page
//Initialize HTML Template @1-A0111C9D
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView");
$Tpl = new clsTemplate();
$Tpl->LoadTemplate(TemplatePath . $TemplateFileName, "main");
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow");
//End Initialize HTML Template
//Show Page @1-5E8220D1
$Button2->Show();
$Go->Show();
$Button1->Show();
$room->Show();
$Tpl->PParse("main", false);
//End Show Page
//Unload Page @1-AB7622EF
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
unset($Tpl);
//End Unload Page
?>