Hi
I am using the fallowing code to give some information back to the user after running some queries. The information will be displayed in row only.
I would like to display the information in this way i.e:
-----------------------------------------
First name | Smith
------------------------------------
last Nmae | Alan
------------------------------------
Arrival date| 28/02/2009
------------------------------------
and so on ......
Any suggestion as I am new to PHP. I have attached the image to show how the information is displayed.
Regards
HB25
I am using the fallowing code to give some information back to the user after running some queries. The information will be displayed in row only.
Code:
<?php
// open database connection code and then my code as follows
$sql="INSERT INTO clients (firstname, surname, address1, address2, town, postcode, telephone, email, cardno, expirydate) VALUES ('$_POST[firstname]','$_POST[surname]','$_POST[address1]',
'$_POST[address2]','$_POST[town]', '$_POST[postcode]','$_POST[telephone]','$_POST[email]','$_POST[cardno]',
'$_POST[expirydate]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$last_insert_client_id = mysql_insert_id();
$sql="INSERT INTO bookings (clientID, roomID, startdate, enddate, adults, children, roomtype, requirements) VALUES ('$last_insert_client_id','NULL','$_POST[startdate]','$_POST[enddate]',
'$_POST[adults]','$_POST[children]','$_POST[roomtype]', '$_POST[requirements]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$last_insert_booking_id = mysql_insert_id();
$result = mysql_query("SELECT * FROM clients WHERE clientID='$last_insert_client_id'");
$result1 = mysql_query("SELECT * FROM bookings WHERE bookingID='$last_insert_booking_id'");
print "Thank you, your booking is complete, and your booking ID number is ".$last_insert_booking_id;
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>address1</th>
<th>address2</th>
<th>town</th>
<th>postcode</th>
<th>telephone</th>
<th>email</th>
<th>Arrival</th>
<th>Departure</th>
<th>Adults</th>
<th>children</th>
<th>Room Type</th>
<th>Requirements</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['clientID'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['surname'] . "</td>";
echo "<td>" .$row['address1'] . "</td>";
echo "<td>" .$row['address2'] . "</td>";
echo "<td>" .$row['town'] . "</td>";
echo "<td>" .$row['postcode'] . "</td>";
echo "<td>" .$row['telephone'] . "</td>";
echo "<td>" .$row['email'] . "</td>";
}
//considering these are the values returned by 1st query (ie., table client)
while($row = mysql_fetch_array($result1)) {
echo "<td>" .$row['startdate'] . "</td>";
echo "<td>" .$row['enddate'] . "</td>";
echo "<td>" .$row['adults'] . "</td>";
echo "<td>" .$row['children'] . "</td>";
echo "<td>" .$row['roomtype'] . "</td>";
echo "<td>" .$row['requirements'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
I would like to display the information in this way i.e:
-----------------------------------------
First name | Smith
------------------------------------
last Nmae | Alan
------------------------------------
Arrival date| 28/02/2009
------------------------------------
and so on ......
Any suggestion as I am new to PHP. I have attached the image to show how the information is displayed.
Regards
HB25