<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Enter An Quote</title>
</head>
<body>
<?php
// ** add_Quote.php
// Script 6.3 **
// This page displays and handles a form for inserting records into the Quotes table.
// Include the MySQL information:
require_once ("../db.php");
if (!$_POST['submit']){ //no data so show the request quote form
echo 'Enter a Quote:<br />
<form action="script_6_3.php" method="post">
Quote ID: <select name="Quote_category_id">';
// Display the Quote categories:
$query_result = mysql_query ('SELECT quotes_id FROM tblquotes ORDER BY quotes_id');
while ($rows = mysql_fetch_array ($query_result, MYSQL_BOTH)) {
echo "<option value=\"$rows[0]\">$rows[0]</option>\n";
}
echo '<input type="submit" name="submit" value="Submit!" />
</form>';
}else{ //form submitted and now request the quote
$result = mysql_query("select * from tblquotes where quote_id = $_POST['Quote_category_id']");
do while ($row=mysql_fetch_array($result)){
//included for simplicity and clarity but not really needed
$quote=$row['quote'];
$author=$row['author'];
// Finish the form:
echo '</select><p />
Quote Author: <input type="text" name="Quote_amount" size="10" maxlength="10" value=\'$author''\'/><p />
Quote: <textarea name="Quote_description" rows="5" cols="40">$quote</textarea> <p />
</form>';
}
// Tidy up (not required):
mysql_free_result($query_result);
mysql_close();
?>
</body>
</html>
hth