D
D
dk-web2015-10-05 13:16:28
PHP
dk-web, 2015-10-05 13:16:28

PHP processing html form or compiling a complex request?

Finally, I got my hands on an old project... of course, after the last months of studying MVC, OOP looked at that code with a smile, but it turns out that even then I could do something...
Now I'm trying to get away from Jquery as much as possible .. And now what I encountered...
Is it possible to find out the type of the form field using PHP tools? That is, somehow define text, checkbox or select?
What additional attributes can be inserted to eat PHP? a la data... It is necessary in some places to transfer more than just value ..
Or does it all need to be hammered into the database?
And in order not to produce questions, to consult ...
Here I am creating a large automated query - ... WHERE 1=1 and a bunch of AND.
AND for now! I form it like this..

$sql="";
   foreach ($_POST as $key => $criteria) {
    $sql="AND $key".$criteria['select']['min'].$criteria['min']." AND $key".$criteria['select']['max'].$criteria['max'];
   }

It turns out something like:
... WHERE 1=1 AND po>=100 AND po<1000
But the problem is that the data is taken from different tables using JOIN
For example:
SELECT * FROM geo_base as a INNER JOIN geo_data as b ON a.id=b.id WHERE...

and here the glued AND is substituted.
Only here indexes? then no ... but as far as I understand, you need to write an index of the table (I'm not sure what this index is called) .. that is, it should be AND a.po или b.population..
Can this be avoided?
Actually something like this ...
p.s. installed Sublime 3 with a number of plugins - extremely satisfied - the speed is incomparable compared to 2 ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
ndbn, 2015-10-05
@ndbn

Is it possible using PHP to find out the type of a form field? That is, somehow define text, checkbox or select?

Types, it would be nice if just the server knew, otherwise how to check the entered data.
Often seen, if the input field is expected to contain a number, it is wrapped in intval($val), or filtered through filter_input()/filter_val().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question