How to use code to work on a page from a MySQL database?

Hi all

First many thanks for looking.

I am putting together a page that selects hotels from a database and i am trying to use include to get a page from each hotel to show. This may sound strange but I am having issues with the SQL so this is the easy way to get over the problem and get it up then I will deal with the SQL later.

Below is the code
[php]
include ‘config.php’;
$query = "SELECT * FROM hotel";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
echo "{$row[‘name’]}
" .
"{$row[‘address’]}
" .
"{$row[‘page’]}

";
}
[/php]

$ page is where I put the include code but it just comes back with it as it has been put in and does not come back with the included page as I hoped it would. When I put the code into the database I use this
[php]include ‘dhotel.php’[/php]

Thanks for looking and any help would be great

Hi All

This has now been resolved by using the code below
[php]include ‘config.php’;
include ‘date.class.php’;
$start = new Date(false ,$d, $m, $y);
$end = new Date(false ,$d1, $m1, $y1);
$query = “SELECT * FROM hotelORDER BY RAND()”;
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
if (mysql_num_rows($result)>0){
$hid = $row[‘hid’];
$result1 = mysql_query (“SELECT * FROM rooms WHERE (hid = ‘$hid’) AND rid NOT IN (SELECT rid FROM bookings WHERE (hid = ‘$hid’) AND ((startdate >= “.$start->getTime().” OR enddate > “.$start->getTime().”) AND (startdate < “.$end->getTime().”)))”);
$num_rows = mysql_num_rows($result1);
echo $row[‘name’]."
";
echo $row[‘hid’]."
";
echo “$num_rows Rows

”;
}

mysql_free_result ($result); // Free up the resources.

mysql_close();[/php]

Thank you for looking

Sponsor our Newsletter | Privacy Policy | Terms of Service