Databases Reference
In-Depth Information
$color.
$shop.
$price)
)
echo "<font color='red'>".
"There must be no empty fields - not updating:<br />".
"([$quantity], [$description], [$color], [$shop], [$price])".
"<br /></font>";
}
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<form action='{$_SERVER["PHP_SELF"]}' method='POST'>";
// Create an HTML table to neatly arrange the form inputs
echo "\n<table border='1'>";
// Create the table headings
echo "\n<tr>" .
"\n\t<th bgcolor='LIGHTGREEN'>ID</th>" .
"\n\t<th bgcolor='LIGHTGREEN'>Description</th>" .
"\n\t<th bgcolor='LIGHTGREEN'>Quantity</th>" .
"\n\t<th bgcolor='LIGHTGREEN'>Color</th>" .
"\n\t<th bgcolor='LIGHTGREEN'>Available from</th>" .
"\n\t<th bgcolor='LIGHTGREEN'>Price</th>" .
"\n\t<th bgcolor='LIGHTGREEN'>Delete?</th>" .
"\n</tr>";
// 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
 
Search WWH ::




Custom Search