Hi!
I want to update data on multiple rows in my table. Such as this :
So what I want to do is to set "open" to 1, on rows with specific id's, and all the others shall have open=0;PHP Code:$mysql->query("UPDATE categories SET open=0");
foreach($p as $value) {
$mysql->query("UPDATE categories SET open=1 WHERE id=" . $value);
}
So if I've got a table like this
And the ID's I want to update is 2 and 5, the table should look like below after the query.Code:_ID___OPEN_ | 1 | 1 | | 2 | 0 | | 3 | 0 | | 4 | 1 | | 5 | 0 |
Is this possible in one query?Code:_ID___OPEN_ | 1 | 0 | | 2 | 1 | | 3 | 0 | | 4 | 0 | | 5 | 1 |
Cheers and Thanks,
Artheus


Reply With Quote

Bookmarks