Hi Jay,
you suggestion does not make any difference.
The problem is that @idsum seems to be destroyed for every row!
Is there any other access method on a query that works properly
or do I have to live with different results of the very same
query asked directly in MySQL and asked through P
[snip]
I would like to be able to sum up a collumns values already in
MySQL. The following query will sum up all values of the column
'id':
SELECT @idsum:=(IFNULL(@idsum, id)+id), id FROM yourtable;
Now a question to the PHP/MySQL experienced: Why does this type
of query not work in combinatio
Hi Jay,
MySQL deserves some more respect. It's language is quite potent.
Have you had a look on COUNT()? It is suited well for... well,
counting.
I would like to be able to sum up a collumns values already in
MySQL. The following query will sum up all values of the column
'id':
SELECT @idsu
[snip]
> Challenge; Can this be made as simple for rows too?
$val)
$rowTotal += $val;
// display whatever is needed from $row
$rowTotals[] = $rowTotal; // or echo it out to the last column of the
table
}
?>
[/snip]
:^]
Or based on the original query;
while($row
Hi Jay,
> while($row = mysql_fetch_object($result)){
>print("" . $row->value . "\n");
>print("" . $row->another_value . "\n");
>$value1 = $value1 + $row->value;
>$value2 = $value2 + $row->another_value;
> }
>
> Challenge; Can this be made as simple for rows too?
$val)
One thing I would add to Jay's out loud thoughts...
Always consider alternative approaches. Using a single query and
calculating the totals at the same time is fine if you have a small
dataset, or (as in this case) are producing page totals (I'm assuming
the dataset is paged to fit all on one pag
6 matches
Mail list logo