Jump to content

display values based on selected


Recommended Posts

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.