Jump to content

[SOLVED] php num rows


onthespot

Recommended Posts

Hey guys, I have included num rows in my script.

 

<?php
$leagues = mysql_query("SELECT `comp_name`, `game`, `format` FROM `competitions` WHERE `comp_type` = 'league' AND format = 'xbox 360'");
$num_rows = mysql_num_rows($leagues);
?>

<table cellspacing="10" width="300">
<tr>
<td></td>
<td></td>
<td></td>
</tr><?

if ($num_rows > 0)
{
while( $row = mysql_fetch_assoc($leagues)) {
extract($row);
$info = explode("_",$row[comp_name]);


?>
<tr>
<td><A HREF="league.php?comp=<? echo $comp_name; ?>"><? echo $info[2]; ?></A></td>
<td><? echo $info[1]; ?></td>
<td><? echo $info[0]; ?></td>
</tr>
<?
}
?>
</table>
<?
}
else
{
echo "There are currently no Xbox 360 Leagues";
}
?>

 

Problem is that with the numrows in there, it messes my css up.

So there must be a reason including it? Can you see anything that isn't what it should be?

Link to comment
https://forums.phpfreaks.com/topic/170901-solved-php-num-rows/
Share on other sites

Problem is that with the numrows in there, it messes my css up.

So there must be a reason including it? Can you see anything that isn't what it should be?

HUh!

I don't see any CSS and have no idea how mysql_num_rows would affect CSS..

 

I would assume you mean the table.. without see more code or knowing whats wrong i would have to guess and say move the open table tag into the if statement ie

<?php
$leagues = mysql_query ( "SELECT `comp_name`, `game`, `format` FROM `competitions` WHERE `comp_type` = 'league' AND format = 'xbox 360'" );
$num_rows = mysql_num_rows ( $leagues );
if ($num_rows > 0) {
?>
<table cellspacing="10" width="300">
<tr>
	<td></td>
	<td></td>
	<td></td>
</tr><?php
while ( $row = mysql_fetch_assoc ( $leagues ) ) {
	extract ( $row );
	$info = explode ( "_", $row [comp_name] );

	?>
   <tr>
	<td><A HREF="league.php?comp=<?php 	echo $comp_name; ?>"><?php echo $info [2];?></A></td>
	<td><?php echo $info [1]; ?></td>
	<td><?php	echo $info [0]; ?></td>
</tr>
   <?php
}
?>
</table>
<?php
} else {
echo "There are currently no Xbox 360 Leagues";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/170901-solved-php-num-rows/#findComment-901395
Share on other sites

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.