Hello.
There was a question of saving the form, where a bunch of fields. It works, but I'm not sure what I'm doing right.
For example, we have a form
<form action="" method="post"> <!-- ЭТО ВСЕ В ЦИКЛЕ --> <input name="1[firstname]" value="" /> <input name="1[secondname]" value="" /> <input name="1[nlastame]" value="" /> <input name="1[phone]" value="" /> <input name="1[address]" value="" /> <!-- ЭТО ВСЕ В ЦИКЛЕ --> <input type="submit" /> </form>
Where 1 is id
Next, I process, let's say
foreach ($_POST AS $id => $value) { $id - ID записи, по которой я обновляю данные $value - содержит массив уже со значениями mysql_query(...запрос обновления...); }
What can be done here not to make a request in a loop when updating and is it possible at all?
At the same time, it turns out that some more fields need to be checked for fullness. You can of course muddish the validation through js, but it would also be useful for the handler to check which fields are needed. I don’t understand how to display errors if the field is not filled, and the rest are filled. Run to save and check for fullness? Can someone tell me how this can be done?
It turns out that how many iterations will be, there will be so many requests that, it turns out to be expensive, if you set 30 per page and in each 10 fields.
That turns out 30 requests and 300 fields. This is if you need to update in one table.
I would appreciate advice.