Obodo Posted November 3, 2021 Share Posted November 3, 2021 In my database table, i have a field for price and quantity. Is there a way I could use a select to get 2 values from the database? What I mean is I will create a select field where when I select wholesale it will bring out the price and quantity and if I select retail, it will bring the price and the quantity. Quote Link to comment https://forums.phpfreaks.com/topic/314157-display-values-based-on-selected/ Share on other sites More sharing options...
requinix Posted November 3, 2021 Share Posted November 3, 2021 The select field should identify the row in the table - not the values in it. So if your "wholesale" row has ID #123 with price 100 and quantity 3, your select would say <option value="123">. You then take that ID and look it up in your database table to get the price and quantity. Why? Because a smart user can change the data in the select to be anything they want, which means I could choose quantity 10000 and price 0.01 if I wanted. "Can't you also change the ID 123 too?" Yes. And you can protect yourself against that far more easily than you can protect against a bad quantity or price. Quote Link to comment https://forums.phpfreaks.com/topic/314157-display-values-based-on-selected/#findComment-1591684 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.