Jiraiya Posted December 12, 2008 Share Posted December 12, 2008 Im having trouble getting this data to be displayed in a table could someone help the code is below. // Make a MySQL Connection $query = "SELECT village, SUM(skill), SUM(health) FROM users GROUP BY village"; $result = mysql_query($query) or die(mysql_error()); $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "Village ". $row['village']. " total power: ". $row['SUM(skill)']; echo "Village ". $row['village']. " total health: ". $row['SUM(health)']; echo "<br />"; } // generate and execute query $query = "SELECT * FROM townranks ORDER BY sk DESC"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if records present if (mysql_num_rows($result) > 0) { // iterate through resultset // print article titles while($row = mysql_fetch_object($result)) { ?> <tr> <td><?php echo $row->townname; ?></td> <td><?php echo $row->hp; ?></td> <td><?php echo $row->sk; ?></td> <td><?php echo $row->kage; ?></td> <td><?php echo $row->people; ?></td> </tr> <table border="1"> <tr> <th>Villag</th> <th>Health</th> <th>Skill</th> <th>Current Hokage</th> <th>Citizens</th> </tr> <?php } } // if no records present // display message else { ?> <p>No press releases currently available</p> <?php } // close database connection mysql_close($connection); ?> Link to comment https://forums.phpfreaks.com/topic/136758-displaying-in-a-table-help/ Share on other sites More sharing options...
Mark Baker Posted December 12, 2008 Share Posted December 12, 2008 Well your <tr> table rows aren't inside your <table> That might have some effect Link to comment https://forums.phpfreaks.com/topic/136758-displaying-in-a-table-help/#findComment-714261 Share on other sites More sharing options...
Jiraiya Posted December 12, 2008 Author Share Posted December 12, 2008 were? Link to comment https://forums.phpfreaks.com/topic/136758-displaying-in-a-table-help/#findComment-714267 Share on other sites More sharing options...
Mark Baker Posted December 12, 2008 Share Posted December 12, 2008 were? Here <tr> <td><?php echo $row->townname; ?></td> <td><?php echo $row->hp; ?></td> <td><?php echo $row->sk; ?></td> <td><?php echo $row->kage; ?></td> <td><?php echo $row->people; ?></td> </tr> <table border="1"> Link to comment https://forums.phpfreaks.com/topic/136758-displaying-in-a-table-help/#findComment-714270 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.