In the traversal result set, determine whether the values of the two cycles are 0. that is to say, & nbsp; Table A contains 10 data records with the field phone. after select, & nbsp; & nbsp; use while traversal to judge in while. if the phone value of $ I and the phone value of $ I + 1 are both equal to 0, then, in the traversal result set, determine whether the values of the two loops are 0.
That is to say, table A has 10 data records and the field is phone. after the select statement is used, the while statement is used to traverse and judge in the while statement, if the phone value of $ I and the phone value of $ I + 1 are both equal to 0, perform related operations. How to write this loop?
The code has been written to this:
$i=0;
while ($row = $db->fetch_array($result)){
$i++;
}
Share:
------ Solution --------------------
$ Last = array ();
While ($ row = $ db-> fetch_array ($ result )){
If ($ last & $ row ['phone'] = 0 & $ last ['phone'] = 0 ){
// Process the code
}
$ Last = $ row;
}
You can also directly query
set @last:='';
select @last as last, phone, @last:=phone from tbl_name
Direct comparison or post-reading
------ Solution --------------------
Reference:
Quote: reference:
Add a counter to determine the continuity of the counter. If yes, execute it. otherwise, reset it.
Otherwise, convert the result to an array and use foreach to perform subscript operations.
I am a newbie. thank you very much for the operation of the counter.
The idea is similar to that of #4, but I used cache data directly, which is more concise than using a counter (the counter is the cache subscript $ I), so I won't be ugly.