Re: [PHP] Calculating Totals from table columns without a second query to the DB

2002-09-09 Thread timo stamm
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

RE: [PHP] Calculating Totals from table columns without a second query to the DB

2002-09-09 Thread Jay Blanchard
[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

Re: [PHP] Calculating Totals from table columns without a second query to the DB

2002-09-07 Thread timo stamm
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

RE: [PHP] Calculating Totals from table columns without a second query to the DB

2002-09-06 Thread Jay Blanchard
[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

RE: [PHP] Calculating Totals from table columns without a second query to the DB

2002-09-06 Thread Jon Haworth
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)

RE: [PHP] Calculating Totals from table columns without a second query to the DB

2002-09-06 Thread Richard Black
ack Senior Developer, DataVisibility Ltd - http://www.datavisibility.com Tel: 0141 951 3481 Email: [EMAIL PROTECTED] -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED]] Sent: 06 September 2002 16:33 To: [EMAIL PROTECTED] Subject: [PHP] Calculating Totals from table columns wi

[PHP] Calculating Totals from table columns without a second query to the DB

2002-09-06 Thread Jay Blanchard
[thinking out loud] For small result sets where I am looking for column totals I generally issue 2 queries to the database, one for the data and one for the totals. This works fine, but for some things the database returns 100's or 1000's of records. To make this easier to use I "page" the records