karimali831 Posted April 13, 2011 Share Posted April 13, 2011 Is it possible to count how many returns there are on a if statement? Where you can see echo 'yes'; it will echo this twice according to my condition, all I want is the the value 2 that it has returned twice... ? while($row = mysql_fetch_array($bookings)) { if(time() > $row['returnby'] && $row['returned']==0) { $books_overdue = count($row['returned']); } if(time() > $row['returnby'] && $row['returned']==1) { $returned_ontime = count($row['returned']); } if(time() <= $row['returnby']) { echo 'yes'; } } thanks for help. Link to comment https://forums.phpfreaks.com/topic/233614-count-return-on-if-statement/ Share on other sites More sharing options...
Maq Posted April 13, 2011 Share Posted April 13, 2011 Is it possible to count how many returns there are on a if statement? Not sure what you mean by this? Count the results from the query? How many IF conditions are true? all I want is the the value 2 that it has returned twice... ? This makes no sense to me. Please elaborate. Link to comment https://forums.phpfreaks.com/topic/233614-count-return-on-if-statement/#findComment-1201157 Share on other sites More sharing options...
karimali831 Posted April 13, 2011 Author Share Posted April 13, 2011 Yes, that's what I mean. How many if conditions are true.. thanks. Link to comment https://forums.phpfreaks.com/topic/233614-count-return-on-if-statement/#findComment-1201159 Share on other sites More sharing options...
Maq Posted April 13, 2011 Share Posted April 13, 2011 Define a variable $x = 0; before the while. In each IF block increment it by 1 $x++; Link to comment https://forums.phpfreaks.com/topic/233614-count-return-on-if-statement/#findComment-1201167 Share on other sites More sharing options...
karimali831 Posted April 13, 2011 Author Share Posted April 13, 2011 thank you works fine. Link to comment https://forums.phpfreaks.com/topic/233614-count-return-on-if-statement/#findComment-1201180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.