Jump to content

Don't know what's wrong


Gotharious

Recommended Posts

Hello all,

I'm having trouble with the following code, it's supposed to go like this, you search for a hotel, choose a room, then it takes you to confirmation page before the paypal, but the problem is, in the confirmation page, it shows everything right, the number of nights, the number of guests, all except the number of rooms, it always give me 0 rooms

 

It's seperated into 3 files, hotelsmanager.php, bookingmanager.php, and book.php

 

here are the codes

 

 while($row = @mysql_fetch_array($result))
	{
		echo "<tr>";
		echo "<td class=\"text\" align=center>".$row['room_type']."</td>";
		echo "<td class=\"text\" align=center>".$row['price_per_day']."</td>";
		echo "<td class=\"text\" align=center>".$row['people']." People</td>";
		echo "<td class=\"text\" align=center>";

		?>

                        <select name="nrooms" id="nrooms" onchange="
                        //alert('<?php echo $row['id'] ; ?>');
                        //alert(this.value);
                        var exist = 0;
                        if(roomids.length > 0)
                        {
			for(var hh = 0;hh < roomids.length; hh++)
			{

				if(roomids[hh] == <?php echo $row['id'] ; ?>)
				{
					exist = 1;
					//alert(hh);
					roomnumar[hh] = this.value;


				}
			}
			if(exist == 0)
			{
			roomids.push(<?php echo $row['id'] ; ?>);
			roomnumar.push(this.value);
			}
                        }
                        else 
                        {
                        	roomids.push(<?php echo $row['id'] ; ?>);
                        	roomnumar.push(this.value);
                        }
                        
                        document.bookingform.roomid.value = roomids;
                        document.bookingform.roomnum.value = roomnumar;
                        
                        
                        
                        ">
                        <option value=0>  0  </option>
                        <?php
                        for($i = 0; $i < $row['available_rooms']; $i++)
                        	{
                        		$nr = $i+1;
                        		$pr=$nr * $row['price_per_day'];
                        		echo "<option value=$nr>$nr ($pr\$)</option>";
                        	}
                        echo "</select>
                        </td>";
                        echo "<td align=center>
                         
                        </td>";
		echo "</tr>";
		echo "<tr>
		<td> </td>
		<td> </td>
		<td> </td>
		<td> </td>
		</tr>";

	}
	echo "<tr class=\"rooms\">
		<td colspan=\"4\"> </td>

		<td align=center><input type=\"submit\" value=\"book\" id=\"bookroom\" name=\"bookroom\"/></td>
		</tr>";
	echo "</table>";
	echo "</form>";
	print_r($_SESSION['order']);

	$_SESSION['order']=0;
	unset($_SESSION['order']);

}

}


?> 

 

then booking info

 

 <?php include("hotelsManager.php"); ?>
<?php include("config.php"); ?>
<?php include("textManager.php"); ?>
<?php
function echoPostedData()
{

	 $dbo = new DB();
	 $hotelObj = new hotelManager();
	 $hotelID = $_POST['hotelid'];
	 $datein = $_POST['datein'];
	 $dateout = $_POST['dateout'];
	 $roomid = $_POST['roomid'];
	 $pr = $_POST['tp'];

	 $_SESSION['hotelID'] = isset($_POST['hotelid']) ? $_POST['hotelid'] : $_SESSION['hotelID'];
	 $_SESSION['datein'] = isset($_POST['datein']) ? $_POST['datein'] : $_SESSION['datein'];
	 $_SESSION['dateout'] = isset($_POST['dateout']) ? $_POST['dateout'] : $_SESSION['dateout'];
         $_SESSION['roomid'] = isset($_POST['roomid']) ? $_POST['roomid'] : $_SESSION['roomid']; 	 


	 $roomsarray = explode(",",$_POST['roomid']);
	 $_SESSION['roomsarray'] = isset($_POST['roomid']) ? explode(",",$_POST['roomid']) : $_SESSION['roomsarray'];
	 $roonsNo = $_POST['nrooms'];
	 $_SESSION['nrooms'] = isset($_POST['roomnum']) ? explode(",",$_POST['roomnum']) : $_SESSION['nrooms']; 

 

Then the confirmation page is

 

   <?php
			  	echoPostedData();
			  ?>
                  </td>
                </tr>
                <tr>
                  <td valign="top"> </td>
                </tr>
              </table>
             
              
              </td>
            </tr>
            <tr>
              <td valign="top"><img src="images/spacer.gif" width="28" height="10" /></td>
            </tr>
            <tr>
              <td valign="top">
              <?php
			if(isset($_POST['bookroom']))
		  {?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.