Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding in php

Status
Not open for further replies.

martinb7

Programmer
Joined
Jan 5, 2003
Messages
235
Location
GB
Hi, i was wondering, would anyone be able to help me add up the total votes here and put it underneath?

Code:
<?php

include (&quot;config1.php&quot;);

$conn = mysql_connect($host, $user, $pass);
mysql_select_db($db, $conn);
$query3 = mysql_query(&quot;SELECT * FROM poll ORDER by views DESC&quot;);

$currentrow =0;  
while ($r = mysql_fetch_array($query3)) {
  	$c = $r[&quot;choise&quot;];
   	$cl = $r[&quot;clink&quot;];
	$v= $r[&quot;views&quot;];
	
$currentrow++;
  if ($currentrow % 2 == 0) {
    $color = &quot;#CCCCCC&quot;;
  } else {
    $color = &quot;#999999&quot;;
  }


?>
    <center>
            <table width=&quot;140&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
        <!--DWLayoutTable-->
        <tr> 
          <td width=&quot;96&quot; height=&quot;19&quot; valign=&quot;top&quot; bgcolor=&quot;<?php echo(&quot;$color&quot;); ?>&quot;> 
            <div align=&quot;center&quot;><a href=&quot;<?php echo($cl); ?>&quot;><?php echo($c); ?></a></div></td>
          <td width=&quot;44&quot; valign=&quot;top&quot;  bgcolor=&quot;<?php echo(&quot;$color&quot;); ?>&quot;> 
            <div align=&quot;center&quot;><?php echo($v); ?></div></td>
        </tr>
      </table>
    </center>
    <?php
} 
	
?>

This will come out something like

Playstation 2 9
Playstation 7
Xbox 6
GameCube 8

Now how in php would you make it add up those results (9,7,6,8) and display them underneath like below??

I want to no how you get the total number of votes!

Playstation 2 9
Playstation 7
Xbox 6
GameCube 8
-------------------
Total votes: 30

Any ideas??

Thanx

Martin
 
thanx, but I already figured that just after my post

thanx neway sleipnir ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top