PHP: html table layout with data coming from query -
i'm trying fix layout of data coming database in way:
the query returning names of games , points awarded each game.
the layout need that:
in 1 row name of game , in row below points, 2 columns , carriage break until results displayed.
please see image, it'll show light:
http://217.116.9.130/wordpress/htmltablefromquery.gif
what have done far following code, cannot display layout needed.
![<?php echo "<table border=1><tr>"; $count=0; $sql2 = "select * games"; $res2= $db_class->select($sql2); if (mysql_num_rows($res2)>0) { while($row2 = $db_class->get_row($res2)){ $gname = $row2['gamename']; $gpoints = $row2['gamepoints']; $count++; echo"<td>".$gname."</td>"; if($count % 2 != 0) { echo "</tr><tr>"; echo"<td>".$gpoints."</td>"; } } } echo "</tr></table>"; ?>
what div
s?
<?php echo "<table border=1><tr>"; $count=0; $sql2 = "select * games"; $res2= $db_class->select($sql2); if (mysql_num_rows($res2)>0) { while($row2 = $db_class->get_row($res2)){ $gname = $row2['gamename']; $gpoints = $row2['gamepoints']; $count++; echo"<td> <div class=\"gname\">".$gname."</div> <div class=\"gpoints\">".$gpoints."</div> </td>"; if($count % 2 != 0) { echo "</tr><tr>"; } } } echo "</tr></table>"; ?>
Comments
Post a Comment