msaz87 Posted December 8, 2009 Share Posted December 8, 2009 Hey all, I'm trying to create a system to check a scheduling tool I'm developing for teams playing at the same time twice (IE: an error). While I've been able to get a system in place that effectively finds these mismatches, it's outputting a little funny and I'm not sure why. In my demo schedule, I've scheduled two teams (Arsenal 1 [216] and Donkeys [281]) to be playing twice at the same time.. and the table looks like this: and the output is: It makes sense to me the Arsenal error would output twice, but why the Donkeys one comes out 11 times... I have no clue... and finally the code: <?php $team_list_query = " SELECT DISTINCT team FROM schedules WHERE league_date = '$league_date' AND league = '$league_selection' ORDER BY team ASC"; $team_list_results = mysql_query($team_list_query) or die(mysql_error()); while($row = mysql_fetch_array($team_list_results)){ $team = $row['team']; $time_list_query = " SELECT DISTINCT gametime FROM schedules WHERE league_date = '$league_date' AND league = '$league_selection'"; $time_list_results = mysql_query($time_list_query) or die(mysql_error()); while($row = mysql_fetch_array($time_list_results)){ $time = $row['gametime']; $team_name_query = " SELECT * FROM team WHERE team_id = '$team'"; $team_name_results = mysql_query($team_name_query) or die(mysql_error()); while($row = mysql_fetch_array($team_name_results)){ $team_name = $row['team']; } $time_strip = strtotime($time); $gametime = date('g:i A', $time_strip); $error_check_query = " SELECT * FROM schedules WHERE league_date = '$league_date' AND league = '$league_selection' AND gametime = '$time' AND team = '$team'"; $error_check_results = mysql_query($error_check_query) or die(mysql_error()); $error_check = mysql_num_rows($error_check_results); if($error_check > 1) { $errors = "<span style=\"color: red\"><li>".$team_name." is scheduled for ".$error_check." games at ".$gametime."</span></li><br/>"; } else { } } if(empty($errors)) { } else { echo $errors; } } if(empty($errors)) { echo "<span style=\"color: green\"><li>The schedule is free of errors!</li></span>"; } else { } echo "</ul>"; ?> Any ideas or help is greatly appreciated... thanks! Link to comment https://forums.phpfreaks.com/topic/184360-odd-outputs-after-some-loops-and-counting-rows/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.