User fills out a web form containing about a dozen or so combo boxes. As each comboBox has its options filled from values contained in a database, this limits what the user can input. However, as we know this can be bypassed, hence the need for validation even on a preset data set. So after I've "cleaned" the input, I need to make sure the values are valid before adding a new row into the database.

Currently, I'm thinking of just doing the following (except with 17 tables):

SELECT * FROM t1,t2,t3 WHERE t1.id = '{$clean['a']}' AND t2.id = '{$clean['b']}' AND t3.id = '{$clean['c']}'

How efficient would that be? Or would there be a better way? This isn't a query ran on every page, only during registration. And though this wouldn't tell me which field is invalid, it would tell me if all values are contained in the database and thus valid or not.

Recommended Answers

All 2 Replies

Mind if I ask if the t1.id, t2.id, t3.id might be unique integer values set to auto-increment when more data is added for choices, or are they something else?

You are correct, the id is just an auto-incremented tinyint. I'm assuming accessing all these tables at once would be better than making multiple queries to check for each one individually.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.