laserlight wrote:Precisely, there was no need to engage in thread necromancy, especially when your proposed solution is wrong anyway. The second assignment to $row should happen at the end of the while loop's body, not at the beginning, otherwise the first row in the result set will be skipped.
I'm sorry about that, I was very tired that day, anyway going into thread necromancy (I like the way you call it 😉 ) soetimes helps other people but the thread author.
Here the code without errors
// my query
$query = "SELECT `field` FROM `table`";
// my db abstraction
sql_select($query,$results);
// This fetch the first data of the resourse into an array
$my_row = mysql_fetch_array($results);
while($my_row){
// DO SOMETHING
// once the first data row is used it gets the next one if available so it MUST be at the end of the cycle
$my_row = mysql_fetch_array($results);
}
Anyway I didn't decide which way is better because assignments in condition generally improve readability even though it's not considered a good "style" practice. Think it depend on the situation, if you ar just assigning the row into an array and nothing more it would be better to do it inside the condition, but if you are doing more then just an assignment it would be better to skip the assignment in condition just to prevent cofunsion (but it's just my oppinion)