Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-01-2006, 08:50 PM   PM User | #1
puja
New Coder

 
Join Date: Apr 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
puja is an unknown quantity at this point
still probs with booking code

hey
im still having problems trying to get my code working for a booking query that i am trying 2 do
the booking is for holiday accommodation and the accommodation is searched for the the first page with details from an accommodation table which has the primary key accommID.
then from those results a radio button is chosen to carry on with the booking for that accommodation. on this booking page the users need to put in the booking start date and booking end date which is to be stored in the booking table.
the booking table has bookingID as the primary key and the accommID as a foreign key to link the to accommID's.
but what i am having problems with is storing the accommID that corresponds to the accomm chosen in the booking table.
i have tried to use hidden fields but it doesnt seem to work!
the following code is for the search results page:
i know i have used the hidden field twice but im not sure where it shud go, ive tried it in both places and it still doesnt work
Code:
$self = $_SERVER['PHP_SELF'];
$accommID = $_POST["accommID"];
$type = $_POST["select_type"];
$sleeps = $_POST["select_sleeps"];
$board = $_POST["select_board"];
$description = $_POST["description"];
$pets_allowed = $_POST["select_pets_allowed"];


//$query = "SELECT type, sleeps, board, description, pets_allowed FROM accommodation WHERE type = '$type' AND sleeps = '$sleeps' AND board = '$board' AND description= '$description' AND pets_allowed = '$pets_allowed'";
$query = "SELECT type, sleeps, board, description, pets_allowed FROM accommodation WHERE type='$type' && sleeps = '$sleeps' && board='$board' && pets_allowed ='$pets_allowed'";
$result = mysql_query ($query) or die(mysql_error());

$num = mysql_num_rows($result);

if ($num > 0){
             echo "<p>There is currently $num accommodation(s). </p>\n";
              echo '<FORM METHOD="POST" ACTION="add_book.php">';
              echo '<table align = "center" border = "1" cellspacing = "0" cellpadding = "5">
              <tr>
              <td align="left"><b>Type</b></td>
              <td align="left"><b>Sleeps</b></td>
              <td align="left"><b>Board</b></td>
              <td align="left"><b>Description</b></td>
              <td align="left"><b>Pets Allowed</b></td>
              <input type="hidden" name="accommID" value="'.$accommID.'">
              </tr>
              ';
              
              while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
                echo '
              <tr>
              <td align="left">'. $row['type']. '</td>
              <td align="left">'. $row['sleeps']. '</td>
              <td align="left">'. $row['board']. '</td>
              <td align="left">'. $row['description']. '</td>
              <td align="left">'. $row['pets_allowed']. '</td>
              <td align=center><input type=radio name=accommID value="'.$row['accommID'].'"></td>
              </tr>
              ';
              }

              echo '</table>';
              echo '&nbsp';
              echo '<center> <input type="submit" value="Continue Booking"></center>';
              
              mysql_free_result($result);
              

              } else {

              	echo '<p class = "error">There are currently no types of accommodation for the choices entered.</p>';
              }

              echo '<input type="hidden" name="accommID" value="'.$accommID.'">';
              echo '</FORM>';

              mysql_close();

and the code for the booking looks like:
Code:
 $accommID = $_POST ["accommID"];
         $book_start = $_POST ["booking_start_date"];
         $book_end = $_POST ["booking_end_date"];

         $query = "INSERT INTO booking (booking_start_date, booking_end_date, accommID) VALUES ('$book_start','$book_end','$accommID')";

         mysql_query($query, $connection) or die (mysql_error());
thanks
puja is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:05 AM.


Advertisement
Log in to turn off these ads.