Mysql select to php string -
i have football site. player can have these results: 0, 1 or 3 (loss, draw, win)
i want see results player got in last 3 matches. want add result (should number combined 3 possible results mentioned before)
this code:
$result = mysql_query("select * events_regged result not null , registrant_name='john' order id desc limit 3") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $form = $row['result']; echo $form; if ($form == '333') {echo 'won 3 times in row';} }
the problem here 3 times number 3 , not number 333. think not need 'while
' statement here.
how can it?
$result = mysql_query("select * events_regged result not null , registrant_name='john' order id desc limit 3") or die(mysql_error()); $maxwins = 0; while($row = mysql_fetch_array( $result )) { $form = $row['result']; if ($form==3) $maxwins++; else $maxwins = 0; if ($maxwins == 3) { echo 'won 3 times in row'; break; } }
Comments
Post a Comment