View Single Post
Old 03-20-2010, 05:35 PM   #2 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

php Code:
$_SESSION['room_price']=$data['room_price'];
$room_price=$_SESSION['room_price'];

$_SESSION['room_type']=$data['room_type'];
$room_type=$_SESSION['room_type'];

$data doesn't exist at this stage where you are setting it. Therefore the above lines are extraneous as you're setting $_SESSION's room_price and room_type key from a NULL variable and then passing it along to others ($room_price and $room_type) which then aren't used. var_dump() any of these variables to check them for yourself.

php Code:
<?php
        //$counter=1;
        while ($data = mysql_fetch_array($result)):
        ?>
      <tr>
     
        <td><?php echo $data['room_type']; ?></td>
        <td><?php echo $data['room_price']; ?></td>
  <td width="153"><label><a href="DisplayDetails.php?id_no=<?php echo $data['id_no'];?>"><strong>Book Now</strong></a></label></td>

 
    </tr>
      <?php
          //$counter++;
          endwhile;
        ?>

Since you are generating a list of data inside of a while loop, passing this information along via session variables would be difficult to nearly impossible. You'd be much better off passing it along via GET.

php Code:
<?php
    while ( $data = mysql_fetch_assoc( $result ) ):
        $q = http_build_query( array( 'id_no' => $data['id_no'], 'room_type' => $data['room_type'], 'room_price' => $data['room_price'] ), '', '&amp;' );
?>
    <tr>
        <td><?php echo $data['room_type']; ?></td>
        <td><?php echo $data['room_price']; ?></td>
        <td width="153"><label><a href="DisplayDetails.php?<?php echo $q ; ?>"><strong>Book Now</strong></a></label></td>
    </tr>
<?php endwhile; ?>

Then in DisplayDetails.php you could grab those values and enter them into the session for use later;

php Code:
if ( isset( $_GET ) ) {

    foreach ( $_GET as $k => $v ) {

        if ( in_array( $k, array( 'id_no', 'room_type', 'room_price' ) ) )
            $_SESSION[$k] = $v

    }

}

Please note that the above example is unsafe and does not include error checking of the values it is receiving. You will have to address this yourself, all the code above does is find the keys it wants to assign to the session and assigns them.
delayedinsanity is offline  
Reply With Quote