Jump to content

Combined Form Values and SQL values


vanris

Recommended Posts

Hi peeps,

 

I'm kinda new here to SQL and PHP stuff. I wanna to ask how do I calculate a value using a form as well as SQL values. For example, if I store the values of a goods in the database, and I enter the quantity into a form, how do i multiple them together using PHP?

 

$computer = $_POST['computer'];

$data = mysql_query("SELECT * FROM product_tbl WHERE product=$computer) or die (mysql_error());

while($info = mysql_fetch_array($data));

$price = $info['price']*$computer

{

Print "<b>Your exposure is: $price

{

?>

 

Pls help. Thanks

Link to comment
https://forums.phpfreaks.com/topic/156216-combined-form-values-and-sql-values/
Share on other sites

Well first of all, your syntax is completely messed up.

 

$computer = $_POST['computer'];
$data = mysql_query("SELECT * FROM product_tbl WHERE product='$computer'") or die (mysql_error());
while($info = mysql_fetch_array($data)) {
$price = $info['price']*$computer
echo "<b>Your exposure is: $price</b>";
}

 

Is that what you want? I'm not fully understanding your issue. If that's not what you want, can you elaborate further? An example would help. =]

oh oh...i mean i want to create something like a calculations table with php and sql...

 

For instance, the product table in SQL contains a list of products and prices. I want to be able to return the values of the products according to the items they choose and multiple it by a value that they key into a form.

 

So its like you buy 2 computers at 1,200 each...so e 1,200 comes from the sql and the 2 quantity comes from the form.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.