ondi Posted July 6, 2008 Share Posted July 6, 2008 Here's my code - the table i print just seems to go on forever! I can't see where it hasn't been closed though, can anyone help? Thanks in advance. <?php // //Check which matche want to be printed // //All // if($defaultshow == 1) { $get_matches = mysql_query(" SELECT O.OpponentName AS hometeam, OP.OpponentName AS awayteam, LM.LeagueMatchHomeGoals AS goals_home, LM.LeagueMatchAwayGoals AS goals_away, LM.LeagueMatchID AS id, DATE_FORMAT(LM.LeagueMatchDate, '$print_date') AS date FROM tplls_leaguematches LM, tplls_opponents O, tplls_opponents OP WHERE O.OpponentID = LM.LeagueMatchHomeID AND OP.OpponentID = LM.LeagueMatchAwayID AND LeagueMatchSeasonID LIKE '$defaultseasonid' ORDER BY LM.LeagueMatchDate DESC LIMIT 11 ",$connection) or die(mysql_error()); } // //Own only // else { $get_matches = mysql_query(" SELECT O.OpponentName AS hometeam, OP.OpponentName AS awayteam, LM.LeagueMatchHomeGoals AS goals_home, LM.LeagueMatchAwayGoals AS goals_away, LM.LeagueMatchID AS id, DATE_FORMAT(LM.LeagueMatchDate, '$print_date') AS date FROM tplls_leaguematches LM, tplls_opponents O, tplls_opponents OP WHERE O.OpponentID = LM.LeagueMatchHomeID AND OP.OpponentID = LM.LeagueMatchAwayID AND LeagueMatchSeasonID LIKE '$defaultseasonid' AND (O.OpponentOwn = '1' OR OP.OpponentOwn = '1') ORDER BY LM.LeagueMatchDate",$connection) or die(mysql_error()); } if(mysql_num_rows($get_matches) < 1) { echo "<b>No matches yet.</b>"; } else { $i = 0; $temp = ''; while($data = mysql_fetch_array($get_matches)) { echo " <tr> <td align=\"left\" valign=\"top\" width=\"0\"> $data[hometeam] $data[goals_home] - $data[goals_away] $data[awayteam] </td> </tr>"; $temp = "$data[date]"; $i++; } } mysql_free_result($get_matches); ?> </table> <?php } ?> </td> </tr> </table> <?php // //INCLUDES FOOTER.PHP // include('footer.php'); ?> Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/ Share on other sites More sharing options...
fanfavorite Posted July 6, 2008 Share Posted July 6, 2008 Can you give a little more information. Are you seeing the data displayed? Is the data duplicating at all or is it just taking along time to display each line of code? Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/#findComment-582930 Share on other sites More sharing options...
bothwell Posted July 6, 2008 Share Posted July 6, 2008 Here's my code - the table i print just seems to go on forever! I can't see where it hasn't been closed though, can anyone help? Thanks in advance. while($data = mysql_fetch_array($get_matches)) { echo " <tr> <td align=\"left\" valign=\"top\" width=\"0\"> $data[hometeam] $data[goals_home] - $data[goals_away] $data[awayteam] </td> </tr>"; $temp = "$data[date]"; $i++; } } mysql_free_result($get_matches); ?> Heh. The above is basically saying "while this is an array, keep incrementing this result table until mysql crashes!" You should count how many matches there are in get_matches first, and then use something like while($data<=$totalmatches) to loop through. Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/#findComment-582937 Share on other sites More sharing options...
fanfavorite Posted July 6, 2008 Share Posted July 6, 2008 Heh. The above is basically saying "while this is an array, keep incrementing this result table until mysql crashes!" No, that part of the code is fine. I use that all the time. It basically allows you to go through all the records that are true to the mysql statement. Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/#findComment-582940 Share on other sites More sharing options...
ondi Posted July 6, 2008 Author Share Posted July 6, 2008 Can you give a little more information. Are you seeing the data displayed? Is the data duplicating at all or is it just taking along time to display each line of code? The data i want to be displayed is shown perfectly, and takes no time, its just that when i include the file into my web page, it seems to go on forever - have a look here: www.walthamforest-fc.co.uk It is the football results on the right side. You will see that it pushes everything downwards. Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/#findComment-582944 Share on other sites More sharing options...
bothwell Posted July 6, 2008 Share Posted July 6, 2008 Can you give a little more information. Are you seeing the data displayed? Is the data duplicating at all or is it just taking along time to display each line of code? The data i want to be displayed is shown perfectly, and takes no time, its just that when i include the file into my web page, it seems to go on forever - have a look here: www.walthamforest-fc.co.uk It is the football results on the right side. You will see that it pushes everything downwards. Oh, I see! I thought it was an infinite loop. A table might be closing prematurely - try taking out the final </td></tr></table> tags right above the footer? Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/#findComment-582949 Share on other sites More sharing options...
ondi Posted July 6, 2008 Author Share Posted July 6, 2008 now that is strange! i tried that earlier but i got unexpected end error messages. Thanks again bothwell! Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/#findComment-582952 Share on other sites More sharing options...
fanfavorite Posted July 6, 2008 Share Posted July 6, 2008 Looks like its all fixed now. Seems Bothwell got to the bottom of it! Link to comment https://forums.phpfreaks.com/topic/113446-i-think-my-table-needs-closing/#findComment-582956 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.