Jump to content

SUM issue.


a1amattyj

Recommended Posts

Hello again, My issue:

 

This php file updates a table (multi_db) where it sets 'posts' for each database > which have their own row..

e.g

NAME      POSTS    ID      MEMBERS

database    1...      1.  ... 5

database2  1...      2.  ... 5

 

php code:

?>
Now Updating Databases . . .
<br /><br /><br />
<?php
require('../mf_operations/config_inc.php');

$get_dbs = mysql_query("SELECT * FROM multi_db");
while($row = mysql_fetch_array($get_dbs)){

$dbidd = $row['id'];

$mf_forums2 = mysql_query("SELECT sum(posts) FROM multi_forums WHERE id = '$dbidd'") or die(mysql_error());
$row = mysql_fetch_array($mf_forums2);
$total = $row["sum(posts)"];

echo 'Database ID: ';
echo $dbidd;
echo '<br />';
echo 'Total Posts '.$total.'';
echo '<br />';
echo '<br />';


}
?>

I havn't put the update in yet, im just getting it to echo correct, echo  =

Now Updating Databases . . .
Database ID: 1
Total Posts 1
Database ID: 2
Total Posts 1

 

Database 1 should be 2, not 1:

multi_forums has two rows, of each has 1 post.

 

ta

Link to comment
https://forums.phpfreaks.com/topic/105578-sum-issue/
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.