Jump to content

Table working? but ugly!


grlayouts

Recommended Posts

The code below works and it serves its prupose but i was wondering if there is an easier way to get the info as making it look nice in html seems very challenging??

 

echo '<table border="0" width="400" bordercolorlight="#808080" bordercolordark="#808080" style="border-collapse: collapse; font-family: Verdana; font-size: 12px" cellspacing="2" cellpadding="2">';

echo '<tr><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>Unit</b></font></td><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>You Have</b></font></td></tr>';

$sql = "SELECT unit,amount FROM army WHERE boss={$userid} AND amount > 0 ORDER BY unit";

$r = mysql_query($sql);

$has = false;

while ($row = mysql_fetch_row($r))

{

   $has = true;

   echo '<tr><td align="center">'.getUnitName($row[0]).'</td><td align="center">'.number_format($row[1]).'</td></tr>';

}

if ($has == false)

{

   echo '<tr><td colspan="2" align="center"><B>None</B></td></tr>';

}



echo '</table><BR>';

Link to comment
https://forums.phpfreaks.com/topic/216790-table-working-but-ugly/
Share on other sites

<?php

?>
<table border="0" width="400" bordercolorlight="#808080" bordercolordark="#808080" style="border-collapse: collapse; font-family: Verdana; font-size: 12px" cellspacing="2" cellpadding="2">
<tr><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>Unit</b></font></td><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>You Have</b></font></td></tr>

<?php
$sql = "SELECT unit,amount FROM army WHERE boss={$userid} AND amount > 0 ORDER BY unit";

$r = mysql_query($sql);

$has = false;

while ($row = mysql_fetch_row($r))

{

   $has = true;
?>
   <tr><td align="center"><?php echo getUnitName($row[0]);?></td><td align="center"><?php echo number_format($row[1]);?></td></tr>
<?php
}

if ($has == false)

{
?>
   <tr><td colspan="2" align="center"><B>None</B></td></tr>
<?php

}
?>
</table><BR>

 

I don't know... Separate the html from php?

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.