Jump to content

Echo table numbers


CEinNYC

Recommended Posts

Hey all -

 

What is the appropriate syntax to echo out each character name (vanity_name), and their total number of "ties" "wins" and "losses"

 

Thanks for your help!

	$q1 = "SELECT Wins, Ties, Losses from game_char WHERE vanity_name='mario'";
	$mario_sql = mysql_query($q1);

<?php echo "Mario: " . $mario_sql; ?>

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/221156-echo-table-numbers/
Share on other sites

^ forgot to execute $q1 before using mysql_fetch_assoc() on the result...

 

$q1 = "SELECT Wins, Ties, Losses from game_char WHERE vanity_name='mario'";
$result = mysql_query($q1) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) 
{
  echo $row['wins'];
}

Link to comment
https://forums.phpfreaks.com/topic/221156-echo-table-numbers/#findComment-1145118
Share on other sites

$query  = "SELECT vanity_name, Wins, Ties, Losses FROM game_char ORDER BY Wins DESC";
$result = mysql_query($query)or trigger_error("MySQL: " . mysql_error());

while($row = mysql_fetch_row($result))
{
echo <<<STATS
<pre>
<span style="font-weight:bold;">$row[0]</span>
Wins:    $row[1]
Ties:    $row[2]
Losses:    $row[3]
</pre>
STATS;
}

 

Link to comment
https://forums.phpfreaks.com/topic/221156-echo-table-numbers/#findComment-1145134
Share on other sites

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.