I am a student working on a practicum problem. I have a mySQL database that
contains the books, their title, and how many are in stock.  When a person
orders one of the books, I want the stock to be adjusted by how many,
quantity, that they chose when the submit button is clicked.  The scripts
are written in PHP.
Here is part of my code:
<P>The book you are ordering:

echo " $booktitle ";

<P>Additional Message:<br>
 <textarea name="message" cols=30 rows=3></textarea>
<INPUT type="submit" value="Send your order.">
<input type=hidden name="booktitle" value="<? print $booktitle; ?>">

 $user = "adminer";
 $pass = "hoosiers";
 $db = "Book Store1";
 $local = "jolinux";
 $link = mysql_connect( "$local", $user, $pass   );
 if (! $link )
   die ( "Couldn't open the database" );
 mysql_select_db( $db, $link )
 or die ( "Couldn't open the $db: ".mysql_error() );

 if ($submit){
 if( $booktitle, 'quantity' ){
$sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE booktitle=$booktitle
AND quantity=quantity";
// $result = mysql_query($mysql);
 }else if(!$submit){
  echo "Your order has not been placed.<p>";

Reply via email to