PHP MySQL更新已选择的行

This is something I used to do in Java, I was wondering if there is an equivelant in PHP.

In Java, I'd do something like this (pseudo only as I've gotten rusty in the last year or so):

preparedStatement = new StringBuilder("SELECT something FROM somewhere");
ResultSet rs = preparedStatement.executeQuery();
while(rs.next())
{
    if (someTest)
    {
        rs.updateRow[1]="someNewValue";
    }
}

This is wide of the mark syntactically (and I bet it won't compile) but I hope it explains the kind of thing I was able to do. Not sure if it saved an actual DB query from being run but it did make my code alot cleaner.

So in PHP, I have something like this:

$query = "SELECT something FROM somewhere";
$result = mysql_query($query, $db);
while ($row = mysql_fetch_assoc($result))
{
    if (someTest)
    {
        //how can I update this row without coding another query?
    }
}

Is there an equivelant to this in PHP?

I'm using the vanilla mysql db methods, not mysqli or that other one (pod or something?) but I think I'd be safe to use mysqli on our servers if I need to.

Any help appreciated

Nope, you could however use mysql_fetch_object with a custom classname, and define a save() method on it that will run the update query for you. Keeps the logic out of the loop and in a Model for that data. Or use an full-blown ORM library which does this kind of thing.

As far as I'm aware, you can't update the row without running another query such as:

UPDATE table SET column1="value" WHERE (column2="value");