Databases Reference
In-Depth Information
if(!mysqli_num_rows($result))
// No; display a notice
echo "\n\t<tr><td colspan='7' align='center'>".
"There are no gifts in the database</td></tr>";
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<tr>" .
"\n\t<td>{$row["gift_id"]}</td>".
"\n\t<td><input name='description[{$row['gift_id']}]' ".
"value='{$row["description"]}' size='60' /></td>".
"\n\t<td><input name='quantity[{$row['gift_id']}]' ".
"value='{$row["quantity"]}' /></td>".
"\n\t<td><input name='color[{$row['gift_id']}]' ".
"value='{$row["color"]}' /></td>".
"\n\t<td><input name='shop[{$row['gift_id']}]' ".
"value='{$row["shop"]}' size='30' /></td>".
"\n\t<td><input name='price[{$row['gift_id']}]' ".
"value='{$row["price"]}' /></td>".
"\n\t<td><a href='{$_SERVER['PHP_SELF']}?".
"action=delete&gift_id={$row["gift_id"]}'>Delete</a></td>".
"\n</tr>";
// Display a row with blank form inputs to allow a gift to be added
echo "\n<tr><td>New item</td>" .
"\n\t<td><input name='description[0]' size='60' /></td>".
"\n\t<td><input name='quantity[0]' /></td>".
"\n\t<td><input name='color[0]' /></td>".
"\n\t<td><input name='shop[0]' size='30' /></td>".
"\n\t<td><input name='price[0]' /></td>".
"\n</tr>";
// End the table
echo "\n</table>";
// Display a submit button and end the form.
echo "\n<input name='update' type='submit' value='Update data' />";
echo "</form>";
}
?>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jack and Jill's Wedding Gift Registry</title>
</head>
<body bgcolor="LIGHTBLUE">
<?php
// Show a logout link and a link to the main page
echo "<a href='logout.php'>Logout</a> | <a href='list.php'>Gift list</a>";
 
Search WWH ::




Custom Search