". "There must be no empty fields - not updating:
". "([$quantity], [$description], [$color], [$shop], [$price])". "
"; } else { // Add or update the gifts table $query = "REPLACE INTO gifts ". "(gift_id, description,shop,quantity,color,price,username) values (". "'$gift_id', '$description', '$shop', $quantity, '$color', '$price', NULL)"; // Run the query through the connection if (@ mysqli_query($connection, $query)==FALSE) showerror($connection); } } // Show the user the gifts for editing // // Parameters: // (1) An open $connection to the DBMS function showgiftsforedit($connection) { // Create an HTML form pointing back to this script echo "\n
"; // Create an HTML table to neatly arrange the form inputs echo "\n"; // Create the table headings echo "\n" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n\t" . "\n"; // Create an SQL query to list the gifts in the database $query = "SELECT * FROM gifts ORDER BY description"; // Run the query through the connection if (($result = @ mysqli_query($connection, $query))==FALSE) showerror($connection); // Check whether we found any gifts if(!mysqli_num_rows($result)) // No; display a notice echo "\n\t"; else // Yes; fetch the gift details a row at a time while($row = @ mysqli_fetch_array($result)) // Compose the data for this gift into a row of form inputs // in the table. // Add a delete link in the last column of the row. echo "\n" . "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n"; // Display a row with blank form inputs to allow a gift to be added echo "\n" . "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n"; // End the table echo "\n
IDDescriptionQuantityColorAvailable fromPriceDelete?
". "There are no gifts in the database
{$row["gift_id"]}Delete
New item
"; // Display a submit button and end the form. echo "\n"; echo "
"; } ?> Jack and Jill's Wedding Gift Registry Logout | Gift list"; echo "\n

Gift editing page

"; // Show the existing gifts for editing showgiftsforedit($connection); ?>