AL123 Posted December 14, 2009 Share Posted December 14, 2009 I have 3 small testing tables: ID TYPE 1 pepperoni 2 C. bacon 3 taco ID TYPE 1 small 2 med 3 large ID TYPE 1 bud 2 hef 3 mil best 4 7up 5 orange 6 coke Each one is a select menu. How would I pass these as variables to the MySql database with one submit button? I could order a small pepperoni and a coke, or a large pepperoni and a coke or a bud. How do I handle all these possibilities 1) on the php end and 2) in the sql statement? This is part of something I have done before from just one table: $UserArr = chk_lgn($_POST['logname'],$_POST['passwd']); $sql = "SELECT UserId ,logname FROM tblPass WHERE logname = '$lname' AND passwd = '$pass' "; These are just general questions of concept/how to proceed. I have tried to make my question as clear as I can, I hope I succeeded. Thanks AL123. Link to comment https://forums.phpfreaks.com/topic/185048-passing-vars-to-the-db/ Share on other sites More sharing options...
cags Posted December 14, 2009 Share Posted December 14, 2009 if you have 3 tables in your database, and they each have a select html element on the page. The <option> value attribute should be set to the ID. You should then have a 4 table for orders. Your SQL statement would be as simple as $topping = $_POST['topping']; $size = $_POST['size']; $drink = $_POST['drink']; INSERT INTO orders (topping, size, drink) VALUES ($topping, $size, $drink) This is a very basic example, for a more complete solution we'd required more details. Link to comment https://forums.phpfreaks.com/topic/185048-passing-vars-to-the-db/#findComment-977108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.