Jump to content

I think my table needs closing?


ondi

Recommended Posts

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

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.

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. 

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.