Jump to content


Photo

multiple query question


  • Please log in to reply
No replies to this topic

#1 peterbarone

peterbarone
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 09 April 2006 - 03:16 AM

Hello can some one help me figure this out. I have to querys that I'm looking to combine them to get one result. Team Name and Points

<?php
include 'config.php';

$result = mysql_query("SELECT *, sum(points) AS points FROM teams,teamscores WHERE teams.teamid = teamscores.team 

GROUP BY teamscores.team")
        
or die("SELECT Error: ".mysql_error()); 
while($row = mysql_fetch_array( $result )) {
print"<table width=\"650px\">";
print"<tr><td>
$row[teamname]</td><td>$row[points]</td></tr>";
print"</table>";
}
 ?>

<?php
include 'config.php';

$result = mysql_query("SELECT *, sum(points) AS points FROM playerpoints,players WHERE players.playerid = 

playerpoints.player GROUP BY player  ORDER BY   points DESC ") 
or die("SELECT Error: ".mysql_error()); 
while($row = mysql_fetch_array( $result )) {
print"<table width=\"650px\">";
print"<tr><td>
$row[playername]</td><td>$row[points]</td></tr>";
print"</table>";
}
 ?>

Right now both return a running points total but I need them to be combined into one total for points




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users