php - update database rows by $_POST data with key as id for row
I have the following $_POST data received from the user
url = "beheer" name = "knowledge" parent_id = "0" url = "asd" name = "adasdas" parent_id = "0" url = "asdasd" name = "asdsadasd" parent_id = "0"
Where the key is the id for each data. I want to loop through all the data and update the rows
this will execute for example:
mysql_query("UPDATE table SET url = 'beheer', name = 'knowledge', parent_id='0' WHERE id = 3");
How can I solve this?
You can do that :
As I see it, the easiest way to solve it would be to use an associative array instead. So you have one variable, called $values, and then add your names to that like this:
This will enable you to iterate over the array using a foreach loop like so.
This is of course a simple example, but it should help.