Sorry edit time limit reach also try out this code I've made sure it worked with the form and change the db fields to your own those are mine for one of my test servers at home(I use xampp, zend server, and wamp on one system).

Heres my html form its fairly basic but its just to show you how to work it.


HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>

<body>

<form method="post" action="process.php">
Select A Cloth Type<br />
<select name="cloth_type">
<option value="AAA">AAA</option>
<option value="BBB">BBB</option>
<option value="CCC">CCC</option>
</select>
<br />
Enter the Quantity<br />
<input type="text" name ="qty" />
<br />

<input type="reset" value="clear" /> &nbsp; <input type="submit" value="send" />
</form>
</body>
</html>
Now you need to create a new database run the query below in either the mysql.exe cmd prompt or in phpmyadmin

Code:
CREATE DATABASE example;

USE example;

CREATE TABLE currency (id INT NOT NULL AUTO_INCREMENT,cloth_type VARCHAR(3) NOT NULL,qty INT NOT NULL,total FLOAT NOT NULL, PRIMARY KEY(id));
Now Here is my php code to process the above html form and output that the POST vars are set and enter them in the data base. Normally you would use a cck-ish style so you have auto code that would process the form so you could make new forms via an admin panel that did not require you to write code to process them. See form generator in google for help with that and also I did not stop execution of the code if there was no db connection which means it will still attempt the queries even though no db connection was made.

PHP Code:
<?php

$cloths 
$_POST['cloth_type'];
$qty $_POST['qty'];
$pay;

$dbHost "localhost";
$dbUser "pein87";
$dbPass "daking";

$DB_CONN = @mysql_connect($dbHost,$dbUser,$dbPass);
if(!
$DB_CONN)
{

    echo 
"error connecting to database" "<br />";

}
$table = @mysql_select_db("example");
if(!
$table)
{

    echo 
"no table was selected" "<br />";

}

echo 
$cloths;
echo 
"<br />";
echo 
$qty;
echo 
"<br />";

if(
$cloths// cloths is not blank
{

switch(
$cloths)
{

    case 
"AAA":
        
$pay 14.15;
        
$amt $qty $pay;
        echo 
"You've orders " $qty " @" "\$" $pay " a piece.";
        echo 
"<br />  Your Total is " "\$" $amt;
        
$Q = @mysql_query("INSERT INTO currency (cloth_type,qty,total) VALUES ('".$cloths."',$qty,$amt)"$DB_CONN);
        if(
$Q)
        {
        
            echo 
"<br />" "Your info has been entered in the database.";
        
        }
        else
        {
        
            echo 
"<br />" "there was a problem adding your data to the database.";
        
        }
        break;
    case 
"BBB":
        
$pay 14.15;
        
$amt $qty $pay;
        echo 
"You've orders " $qty " @" "\$" $pay " a piece.";
        echo 
"<br />  Your Total is " "\$" $amt;
        
$Q = @mysql_query("INSERT INTO currency (cloth_type,qty,total) VALUES ('".$cloths."',$qty,$amt)"$DB_CONN);
        if(
$Q)
        {
        
            echo 
"<br />" "Your info has been entered in the database.";
        
        }
        else
        {
        
            echo 
"<br />" "there was a problem adding your data to the database.";
        
        }
    break;
    case 
"CCC":
        
$pay 15.85;
        
$amt $qty $pay;
        echo 
"You've orders " $qty " @" "\$" $pay " a piece.";
        echo 
"<br />  Your Total is " "\$" $amt;
        
$Q = @mysql_query("INSERT INTO currency (cloth_type,qty,total) VALUES ('".$cloths."',$qty,$amt)"$DB_CONN);
        if(
$Q)
        {
        
            echo 
"<br />" "Your info has been entered in the database.";
        
        }
        else
        {
        
            echo 
"<br />" "there was a problem adding your data to the database.";
        
        }
    break;
    default:
        echo 
"<br />" "No Item was Selected please select and item.";
    break;

}

}

?>
See how it is multiplying the $qty before the $pay before its being added to the database? For reference you need to add a shopper id and purchase id so that you can get that info or you'll need to use

PHP Code:
$tot_rows = @mysql_query("SELECT COUNT(*) FROM currency"$DB_CONN);

$last_row = @mysql_query("SELECT * FROM currency LIMIT $tot_rows, 1"$DB_CONN);

while(
$rowArray = @mysql_fetch_assoc($last_row))
{

echo 
"ID: " $rowArray[id] . " cloth type: " $rowArray[cloth_type] . " Quantity: " $rowArray[qty] . " Total Cost: " $rowArray[total];


Heres how it would look in an if condition statement

PHP Code:
<?php 

$cloths 
$_POST['cloth_type']; 
$qty $_POST['qty']; 
$pay

$dbHost "localhost"
$dbUser "pein87"
$dbPass "daking"

$DB_CONN = @mysql_connect($dbHost,$dbUser,$dbPass); 
if(!
$DB_CONN


    echo 
"error connecting to database" "<br />"


$table = @mysql_select_db("example"); 
if(!
$table


    echo 
"no table was selected" "<br />"



echo 
$cloths
echo 
"<br />"
echo 
$qty
echo 
"<br />"

if(
$cloths// cloths is not blank 
{
if (
$cloths == "AAA" || $cloths == "BBB")
{

$pay 14.15
        
$amt $qty $pay
        echo 
"You've orders " $qty " @" "\$" $pay " a piece."
        echo 
"<br />  Your Total is " "\$" $amt
        
$Q = @mysql_query("INSERT INTO currency (cloth_type,qty,total) VALUES ('".$cloths."',$qty,$amt)"$DB_CONN); 
        if(
$Q
        { 
         
            echo 
"<br />" "Your info has been entered in the database."
         
        } 
        else 
        { 
         
            echo 
"<br />" "there was a problem adding your data to the database."
         
        }

}
else if(
$cloths == "CCC")
{

$pay 15.85
        
$amt $qty $pay
        echo 
"You've orders " $qty " @" "\$" $pay " a piece."
        echo 
"<br />  Your Total is " "\$" $amt
        
$Q = @mysql_query("INSERT INTO currency (cloth_type,qty,total) VALUES ('".$cloths."',$qty,$amt)"$DB_CONN); 
        if(
$Q
        { 
         
            echo 
"<br />" "Your info has been entered in the database."
         
        } 
        else 
        { 
         
            echo 
"<br />" "there was a problem adding your data to the database."
         
        }

}
else
{

echo 
"No Cloth Value selected please select a cloth type.";

}
}
?>
Last pointer make sure to check to make sure that the user submitted values are the data type you want. For numbers use

PHP Code:
if(!is_numeric($myVar))
{

echo 
"not a number";

}
else
{

echo 
"is a number";


If you dont check the data you can get hacked and also strip tags, html special characters, and possibly strip out script tags. You can use built in functions for this to.

PHP Code:
function clean($str)
{

strip_tags($str); // strip html tags

htmlspecialchars($str); //turns them into there form so & would be &amp;

return $str;


Last edited by pein87; 30Dec2010 at 09:08..