Jump to content

[SOLVED] php database echo


dezkit

Recommended Posts

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. :P

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 :P

 

 

 

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.