". "There are no gifts described in the system!"; else { // Yes; display the gifts // If we're showing the available gifts, then set up // a query to show all unreserved gifts (where username IS NULL) if ($show_user_selection == SHOW_UNRESERVED_GIFTS) $query = "SELECT * FROM gifts WHERE username IS NULL ". "ORDER BY description"; else // Otherwise, set up a query to show all gifts reserved by // this user $query = "SELECT * FROM gifts WHERE username = '". $_SESSION['username']."' ORDER BY description"; // Run the query through the connection if (($result = @ mysqli_query($connection, $query))==FALSE) showerror($connection); // Did we get back any rows? if (@ mysqli_num_rows($result) == 0) { // No data was returned from the query. // Show an appropriate message if ($show_user_selection == SHOW_UNRESERVED_GIFTS) echo "\n

No gifts left!

"; else echo "\n

Your Basket is Empty!". "

"; } else { // Yes, so show the gifts as a table echo "\n"; // Create some headings for the table echo "\n" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n"; // Fetch each database table row of the results while($row = @ mysqli_fetch_array($result)) { // Display the gift data as a table row echo "\n" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n\t"; // Are we showing the list of gifts reserved by the // user? if ($show_user_selection == SHOW_UNRESERVED_GIFTS) // No. So set up an embedded link that the user can click // to add the gift to their shopping list by running // action.php with action=add echo "\n\t"; else // Yes. So set up an embedded link that the user can click // to remove the gift to their shopping list by running // action.php with action=remove echo "\n\t"; } echo "\n
QuantityGiftColourAvailable FromPriceAction
{$row["quantity"]}{$row["description"]}{$row["color"]}{$row["shop"]}{$row["price"]}". "Add to Shopping List". "Remove from Shopping list
"; } } } ?> Jack and Jill's Wedding Gift Registry Logout"; // Check whether the user is Jack or Jill (username is 'jack' or // 'jill'); if so, show a link to the gift editing page. if($_SESSION['username']=="jack" || $_SESSION['username']=="jill") echo " | Edit gifts"; // Connect to the MySQL DBMS and use the wedding database - // credentials are in the file db.php if(!($connection= @ mysqli_connect( $DB_hostname, $DB_username, $DB_password, $DB_databasename))) showerror($connection); // Pre-process the message data for security if(count($_GET)) $message = clean($_GET["message"], 128); // If there's a message to show, output it if (!empty($message)) echo "\n

". urldecode($message)."

"; echo "\n

Here are some gift suggestions

"; // Show the gifts that are still unreserved showgifts($connection, SHOW_UNRESERVED_GIFTS); echo "\n

Your Shopping List

"; // Show the gifts that have been reserved by this user showgifts($connection, SHOW_GIFTS_RESERVED_BY_THIS_USER); ?>