Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_SESSION["productSelected"]))
- {
- ?>
- <b>No item(s) in basket!</b>
- <?php
- }
- else{
- $conn = pg_connect("host=db.dcs.aber.ac.uk port=5432 dbname=teaching user=csguest password=rohishe");
- ?>
- <table border='1'> <tr><th>ID#</th><th>Title</th><th>Platform</th><th>Description</th><th>Price (£)</th><th>User</th></tr>
- <?php
- // begin debugging products //
- echo '<pre>' . print_r($_SESSION['productSelected']) . '</pre>';
- //end debugging products //
- foreach($_SESSION["productSelected"] as $id){
- $res = pg_query ($conn, "select * from CSGames WHERE refnumber='$id' order by refnumber");
- while ($row = pg_fetch_row($res))
- {
- //debug each row returned //
- echo '<pre>' . print_r($row) . '</pre>';
- //end debugging each row returned //
- echo "<tr>";
- for ($j = 0; $j < pg_num_fields($res); $j++)
- {
- echo "<td>" . $row[$j] . "</td>";
- }
- echo "</tr>";
- }
- //are you 100% sure this is correct?
- //I'm pretty sure that pg_fetch_row returns a standard array (indexed with numbers)
- //rather than with names
- //Don't you have to use pg_fetch_assoc to retrieve items as an associative array?
- //also, you've used numbers up there ^^ in the forloop, which makes me think this is the issue
- $total += $row['price'];
- }
- ?>
- </table>
- <!--</form>-->
- <form action='clearBasket.php' method='post'>
- <p><input type='submit' value='Clear Basket' /></p>
- </form>
- <?php
- }
- ?>
Add Comment
Please, Sign In to add comment