grlayouts Posted October 25, 2010 Share Posted October 25, 2010 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 More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 How much more straight forward could it be, and still be able to do virtually anything you want it too? Link to comment https://forums.phpfreaks.com/topic/216790-table-working-but-ugly/#findComment-1126253 Share on other sites More sharing options...
xjasonx Posted October 25, 2010 Share Posted October 25, 2010 <?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? Link to comment https://forums.phpfreaks.com/topic/216790-table-working-but-ugly/#findComment-1126278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.