php - update database rows by $_POST data with key as id for row
388
I have the following $_POST data received from the user
url[3] = "beheer"
name[3] = "knowledge"
parent_id[3] = "0"
url[4] = "asd"
name[4] = "adasdas"
parent_id[4] = "0"
url[5] = "asdasd"
name[5] = "asdsadasd"
parent_id[5] = "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?
Answer
Solution:
You can do that :
Answer
Solution:
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.