FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Getting the Total





fizzo
Im asking for a little help from this one guys..
I want to get the total of a specific data stored on one of my columns in the database i have and display it on my PHP Page

You can take a look at this image for you to see the Column on my database where i want to get the total... of all that are stored in there...




Heres the chunk of codes on my page where i want to display the total of the salaries...
I want to place it on the bottom of the page...
Thanks for helping

Code:
<?php
$con = mysql_connect("localhost","DATABASE","PASSWORD");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("DATABASE", $con);

$result = mysql_query("SELECT * FROM Players WHERE Team = '0' ORDER BY Overallrtg DESC");

echo"<table border='0'><br><br><img border=0 src=http://nclballers.com/files/images/atl_banner.jpg width=595 height=24><br><img border=0 src=http://nclballers.com/files/images/atl_logo.gif width=125 height=125><b><font size=6>TEAM ROSTER</font>
<tr>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1 face=Verdana color=white></th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1 face=Verdana color=white>PLAYER</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1 face=Verdana color=white>CONTRACT SIGNED</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1 face=Verdana  color=white >YR</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>OV</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>RNG</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>FG</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>3PT</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>FT</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DNK</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>STL</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>BLK</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>OR</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DR</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>BH</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>OA</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DA</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>SP</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>QCK</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>JMP</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DRB</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>STG</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>HRD</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>IS</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>PRI</th>
</tr></font>";
while($row = mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td bgcolor=#666666>"."</td>";
  echo "<td bgcolor=#666666>"."<b>"."<a href=http://www.ayc.frih.net/WBA/PlayerPage.php?Playerid=".$row['Playerid'].">".$row['Fname'] . " " . $row['Name']."</a>" ."</b>"."<br>". "<b>#"."</b>".$row['Number']." "."[" .$row['Position'].",".$row['Position2']."]"."</td>";
  echo "<td bgcolor=#666666>" .$row['Salarysign']." "."for"." ".$row['Contractsign']."</td>";
  echo "<td bgcolor=#666666>" . $row['Yearsexp'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Overallrtg'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Dshootrang'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Fgpbase'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Threeptbas'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Ftpbase'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Dnkability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Stlability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Blkability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Oreability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Dreability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Balability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Offability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Defability'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Speed'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Quick'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Jump'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Dribble'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Dstrength'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Dhardy'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Insidesc'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['Primacy'] . "</td>";
  echo "</tr>";
  echo "<br>"."<td bgcolor=#666666>"."SALARY CAP"."</td>"
  }
echo "</table>";

mysql_close($con);
?>


Thanks a lot have a nice day!
LukeakaDanish
Use the following mySQL query:

Code:
SELECT SUM(salary_sign) FROM Players;


(EDIT: not sure if you want the where bit, figure that yourself)

Then display the info with php in whichever way you like

(I will help you with that as well if you want)
fizzo
what specific thing will i do? where will i place the codes? thanks a lot!
LukeakaDanish
At the bottom, before mysql_close(), but after the while loop add

Code:


$result = mysql_query("SELECT SUM(salary_sign) FROM Players") or die(mysql_error());
$result = mysql_fetch_assoc($result);
echo "Total salary = '.$result['SUM(salary_sign)'];

Related topics
Do you read comics? What title?
Top 10s of the Forum
Getting paid online?
Top 14 Humor of Getting married
Jackson - Not Guilty
Complete Tutorial LINKS for every language
Poor sports bring down gaming
Photoshop CS2 Total Training Video Workshop
Need help wi th IPN's ....
Cash Mod phpbbb
mysql insert into multiple tables at once?
BBC Headline :US warns of further bank failures
It's getting huge! 0.o
Thinking of getting a domain.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.