dezkit Posted July 13, 2008 Share Posted July 13, 2008 i have a table set up id | league | wins | losses | ties 1 | CAL-O | 2 | 2 | 0 2 | CEVO-A| 0 | 0 | 0 is it possible to echo the table as CAL-O: 2-2-0 CEVO-A: 0-0-0 if yes, can i get the code? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 13, 2008 Share Posted July 13, 2008 Course it's possible... <table border="0" width="100%" cellpadding="1" cellspacing="0"> <tr> <td>League</td> <td>Wins</td> <td>Losses</td> <td>Ties</td> </tr> <?php $query = mysql_query("SELECT * FROM `table`"); if(mysql_num_rows($query) == 0){ ?> <tr> <td colspan="4">There is no data.</td> </tr> <?php }else{ while($r = mysql_fetch_array($query)){ $league = $r['league']; $wins = $r['wins']; $losses = $r['losses']; $ties = $r['ties']; ?> <tr> <td><?php echo $league; ?></td> <td><?php echo $wins; ?></td> <td><?php echo $losses; ?></td> <td><?php echo $ties; ?></td> </tr> <?php } } ?> </table> Wrote that on the fly so it may have errors. Quote Link to comment Share on other sites More sharing options...
dezkit Posted July 13, 2008 Author Share Posted July 13, 2008 hmm thats weird. it doesn't show the data oO edit: the "There is no data." doesn't show, and so doesn't the data. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 13, 2008 Share Posted July 13, 2008 You didn't copy and paste did you? You should change it around to suit your needs. Quote Link to comment Share on other sites More sharing options...
dezkit Posted July 13, 2008 Author Share Posted July 13, 2008 yeah, i changed the `table` part... Quote Link to comment Share on other sites More sharing options...
dezkit Posted July 13, 2008 Author Share Posted July 13, 2008 what the... <?php $result = mysql_query("SELECT * FROM matches") or die(mysql_error()); echo "<table>"; echo "<tr> <th>League</th> <th>Wins</th> <th>Losses</th> <th>Ties</th></tr>"; while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['league']; echo "</td><td>"; echo $row['wins']; echo "</td><td>"; echo $row['losses']; echo "</td><td>"; echo $row['ties']; echo "</td></tr>"; } echo "</table>"; ?> doesn't work too Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 13, 2008 Share Posted July 13, 2008 Haha. That's good. Well it should work, depending on how you've implemented it. Quote Link to comment Share on other sites More sharing options...
dezkit Posted July 13, 2008 Author Share Posted July 13, 2008 Oh wow, im so stupid, i was using the wrong table name, LOL. topic solved thanks for the code! <3 Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 13, 2008 Share Posted July 13, 2008 Haha nice, no worries. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.