SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with calling variables from a databse

    can anyone tell me why the query won't work.
    it just says tht the cart is empty

    //gets all the bed and breakfasts in the shopping cart
    $result = @mysql_query("Select TABLE1.house_id,TABLE1.house AS Name, TABLE1.no_single AS Single_Booked,TABLE1.no_double AS Double_Booked, TABLE2.price_single AS Single_Price, TABLE2.price_double AS Double_Price,booking.date_book AS Arrive,TABLE1.date_leave AS Depart,TABLE1.num_days AS Days from TABLE1,TABLE2 WHERE session = '$session' AND TABLE1.house_id = TABLE2.house_id ORDER BY date_book");

    if ( !$result ) //Error with query
    { echo " <p>Sorry - Error performing query : ".mysql_error()."</p>";
    exit();
    }

    if ( mysql_affected_rows() == 0 ): // no records obtained from the database
    ?>
    <h2>Cart is empty</h2>
    <?php
    else: // records have been obtained from the database.
    ?>
    <table >
    <caption><h2> Your Shopping Cart</h2></caption>
    <tbody>
    <tr >
    <td>
    <h3>This is what you have in your cart.</h3>
    <table border=1 cellpadding=2>
    <thead>
    <tr><th>Name</th><th>Single Room</th><th>Double Room</th><th>Single Price</th><th>Double Price</th><th>Arrive Date </th><th>Depart Date</th><th>Days</th></tr>
    </thead>
    <tbody>
    <?php
    //display the list of accomodation.
    while( $row = mysql_fetch_array ( $result ) )
    {
    ?>
    <tr><td><?php echo $row["Name"];?></td>
    <td><?php echo $row["Single_Booked"];?></td>
    <td><?php echo $row["Double_Booked"];?></td>
    <td><?php echo $row["Price_Single"]; ?></td>
    <td><?php echo $row["Price_Double"]; ?></td>
    <td><?php echo $row["Arrive"]; ?></td>
    <td><?php echo $row["Depart"]; ?></td>
    <td><?php echo $row["Days"]; ?></td></tr>
    <?php
    }
    ?>

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysql_error()'s your friend

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •