Quote
--
-- Database: `h_reservation`
-- --------------------------------------------------------
-- Table structure for table `guest_info`
--
CREATE TABLE IF NOT EXISTS `guest_info` (
`guest_id` int(11) NOT NULL AUTO_INCREMENT,
`room_type` varchar(25) NOT NULL,
`check_in` date NOT NULL,
`check_out` date NOT NULL,
PRIMARY KEY (`guest_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
-- Database: `h_reservation`
-- --------------------------------------------------------
-- Table structure for table `guest_info`
--
CREATE TABLE IF NOT EXISTS `guest_info` (
`guest_id` int(11) NOT NULL AUTO_INCREMENT,
`room_type` varchar(25) NOT NULL,
`check_in` date NOT NULL,
`check_out` date NOT NULL,
PRIMARY KEY (`guest_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
<?php
$single = "single room";
$double = "double room";
$standard = "standard twin";
$deluxe = "deluxe double";
$mode = "no selected";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="getreserve3.php" method="get">
<select name="room" >
<option value="single room">single room</option>
<option value="double room">double room</option>
<option value="standard">standard twin</option>
<option value="deluxe">deluxe double</option>
</select>
<input type=submit value=GENERATE>
</form>
<?php
$username = "root";
$password = "";
$host = "localhost";
$database = "h_reservation";
$connection = @mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
$db = @mysql_select_db($database) or die("Can not select the database: ".mysql_error());
if($_GET)
{
if($single){
$mode = "single room";
}
else if($double){
$mode = "double room";
}
else if($standard){
$mode = "standard twin";
}
else if($deluxe){
$mode = "deluxe double!";
}
else
$mode="null";
echo "
<h3> room type : $mode </h3>
<hr>
";}
//DISPLAYING CONTENT!!
$select = mysql_query("SELECT * FROM guest_info where room_type = '$mode'");
$total = 0;
while($row = mysql_fetch_array($select)){
echo $row['guest_id'] . "<br>" . "<br>";
$total = $total + 1 ;
}
//COUNTING CONTENT
echo "-----------------total number of reservation-----------------------" . "<br>" . "<br>";
echo $total;
?>
</body>
</html>
when i run this theres no error but.. it always return single room value :crying:
i dont know where the error is anyone? i need help with this
thanks a lot :love:
Edited by hardinera, 11 March 2010 - 06:06 PM.


Sign In
Create Account


Back to top









