Hi there pls refer to the following codes
CODE
<?php
include "dbFunction.php";
/*Array ( [spapackage] => 1 [name] => [email] => [telephone] => [hiddenField] => member_id,
password [member_id] => [day] => 1 [month] => Jan [year] => 2008 [time] => 1 [Submit] => Submit ) */
$package = $_POST['spapackage'];
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$member = $_POST['member_id'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$time = $_POST['time'];
$roomId = "";
$location="/paradigm/thankyou.html";
$con = connect();
$rs3 = mysql_query("Select * from room_aspara where packageId = '".$package."'");
//echo "Select * from room where packageId = '".$package."'";
while ($row3 = mysql_fetch_array($rs3))
{
$rs1 = mysql_query("Select count(*) as 'count' from reservation_aspara where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and reservation_aspara.roomId = '". $row3['roomId']."'");
$row1 = mysql_fetch_array($rs1);
if ($row1['count'] == 0)
{
$roomId = $row3['roomId'];
$roomName=$row3['roomName'];
$roomNumber=$row3['roomNumber'];
}
}
if ($roomId != "")
{
mysql_query("Insert into reservation_aspara (name, contact, roomId, apptMonth, apptYear, apptDay, membershipId, email, time)
values ('$name', '$telephone', '$roomId', '$month', '$year', '$day', '$member', '$email', '$time')");
$reservationID= mysql_query("select reservationId from reservation_aspara where roomId='".$roomId."' and time='".$time."' and apptDay='".$day."' and apptMonth='".$month."' and apptYear='".$year."'"); //echo "Insert into reservation (name, contact, roomId, apptMonth, apptYear, apptDay, membershipId, email, time) values ('$name', '$telephone', '$roomId', '$month', '$year', '$day', '$member', '$email', '$time')";
//echo "Registration successful. Your room id is ". $roomId;
header("Location:confirmation_1.php?roomName=".$roomName."&roomId=".$roomId."&name=".$name."&roomNumber=".$roomNumber."&reservationId=".$reservationID); }
else
{
//echo "no room";
header("Location:$location");
}
/*
$rs1 = mysql_query("Select COUNT(*) as 'count' from reservation, room where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and room.packageId = '". $package."' and reservation.roomId = room.roomId");
//echo "Select COUNT(*) from reservation, room where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and room.packageId = '". $package."' and reservation.roomId = room.roomId";
$rs2 = mysql_query("Select COUNT(*) as 'count' from room where packageId = '".$package."'");
$row1 = mysql_fetch_array($rs1);
$row2 = mysql_fetch_array($rs2);
if ($row1['count'] == 0)
{
$rs3 = mysql_query("Select * from room where packageId = '".$package."'");
$row3 = mysql_fetch_array($rs3);
$roomid = $row3['roomId'];
//$rs3 = mysql_query("Select * as 'count' from reservation, room where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and room.packageId = '". $package."' and reservation.roomId = room.roomId");
//
}
else if ($row1['count'] == $row2['count'])
{
$roomid = "";
}
else
{
} */
?>
Pls refer to the specific lines
$reservationID= mysql_query("select reservationId from reservation_aspara where roomId='".$roomId."' and time='".$time."' and apptDay='".$day."' and apptMonth='".$month."' and apptYear='".$year."'");
-------------------------------------------------------------------------------------
header("Location:confirmation_1.php?roomName=".$roomName."&roomId=".$roomId."&name=".$name."&roomNumber=".$roomNumber."&reservationId=".$reservationID);
----------------------------------------------------------------------------------
I have coded these lines to retrieve the reservation ID from the reservation_aspara table to and store it into a variable called $reservationID, before passing it into the header() tag to link it to the confirmation_1.php page.
Note that the reservationId is the primary key of the reservation_aspara table, and will be auto incremented whenever an entry is appended to the table.
However in the confirmation_1.php page, the reservation ID failed to appear, instead this message "Reservation Id: Resource id" appears. What does the Resource id denotes? And how to recode it so that the actual reservation id will appear?
This post has been edited by PHP_noob: 8 Jun, 2008 - 09:23 AM