vanris Posted April 30, 2009 Share Posted April 30, 2009 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 More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 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. =] Link to comment https://forums.phpfreaks.com/topic/156216-combined-form-values-and-sql-values/#findComment-822426 Share on other sites More sharing options...
vanris Posted April 30, 2009 Author Share Posted April 30, 2009 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. Link to comment https://forums.phpfreaks.com/topic/156216-combined-form-values-and-sql-values/#findComment-822458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.