Jump to content

[SOLVED] align table in php


dezkit

Recommended Posts

i want to align every field in a table.

see image:

2lcp76.jpg

 

i want so that Dynamic gaming, section 13, and everyother field to be aligned, as do i want the 16-0, 14-16 and etc.

 

here is my code:

		<table cellspacing="0" cellpadding="2">
			<?
			$i = 0;
	while($r = mysql_fetch_array($q)) {
		$i += 1;
		$winner = split("-",$r['score']);
		if($winner[0] > $winner[1]) {
			$status = "<td class=\"win\">Won</td>";
		} else if($winner[0] < $winner[1]) {
			$status = "<td class=\"loss\">Loss</td>";
		} else {
			$status = "<td class=\"tie\">Tie</td>";
		}
		?>
		<tr class="row<?=($i&1)?>">
			<td>[<?=$r['team1']?>] <?=$r['team2']?></td>
			<td class="score"><?=$r['score']?></td>
			<?=$status?>
		</tr>
		<?if($r['info'] != "") { ?>
		<tr class="row<?=($i&1)?>">
<td colspan="3" class="comments"><i>
HLTV Demo: <a href="demos/<?=$r['info']?>">download</a>
</i></td>
		</tr>
		<? }
	}
	?></table><?
	} else {
		echo "We haven't played any matches yet!";
	}
	?>

Link to comment
https://forums.phpfreaks.com/topic/114498-solved-align-table-in-php/
Share on other sites

Try this:

 

<table cellspacing="0" cellpadding="2">
			<?
			$i = 0;
	while($r = mysql_fetch_array($q)) {
		$i += 1;
		$winner = split("-",$r['score']);
		if($winner[0] > $winner[1]) {
			$status = "<td class=\"win\">Won</td>";
		} else if($winner[0] < $winner[1]) {
			$status = "<td class=\"loss\">Loss</td>";
		} else {
			$status = "<td class=\"tie\">Tie</td>";
		}
		?>
		<tr class="row<?=($i&1)?>">
			<td>[<?=$r['team1']?>]</td>
<td><?=$r['team2']?></td>
			<td class="score"><?=$winner[0]?> -</td>
			<td class="score"><?=$winner[1]?></td>
			<?=$status?>
		</tr>
		<?if($r['info'] != "") { ?>
		<tr class="row<?=($i&1)?>">
<td colspan="3" class="comments"><i>
HLTV Demo: <a href="demos/<?=$r['info']?>">download</a>
</i></td>
		</tr>
		<? }
	}
	?></table><?
	} else {
		echo "We haven't played any matches yet!";
	}
	?>

 

Of course you'll need to format it a bit more....

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.