Jump to content

displaying in a table help


Jiraiya

Recommended Posts

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

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">

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.