Forums
This topic is locked
php repeat region assign hidden field
Posted 18 Sep 2010 14:02:22
1
has voted
18 Sep 2010 14:02:22 Chris Trace posted:
hi therei have a repeat region which works no problem.
I have a number of hidden fields in each recordset repeat.
how can i sum a series of fields within each recordset then sum the sub totals of those recordsets?
any help is greatly appreciated
cheers
Replies
Replied 19 Sep 2010 13:29:16
19 Sep 2010 13:29:16 student 101 replied:
First off;
Post your database and form fields.
OR you could use this idea:
totals.php
Post your database and form fields.
OR you could use this idea:
CREATE TABLE `products` ( `id` varchar(30) NOT NULL default '', `name` varchar(60) NOT NULL default '', `type` varchar(30) NOT NULL default '', `price` decimal(10,2) NOT NULL default '0.00', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- Dumping data for table `products` INSERT INTO `products` VALUES ('123451', 'Park''s Great Hits', 'Music', 19.99); INSERT INTO `products` VALUES ('123452', 'Silly Puddy', 'Toy', 3.99); INSERT INTO `products` VALUES ('123453', 'Playstation', 'Toy', 89.95); INSERT INTO `products` VALUES ('123454', 'Men''s T-Shirt', 'Clothing', 32.50); INSERT INTO `products` VALUES ('123455', 'Blouse', 'Clothing', 34.97); INSERT INTO `products` VALUES ('123456', 'Electronica 2002', 'Music', 3.99); INSERT INTO `products` VALUES ('123457', 'Country Tunes', 'Music', 21.55); INSERT INTO `products` VALUES ('123458', 'Watermelon', 'Food', 8.73);
totals.php
// Make a MySQL Connection $query = "SELECT type, SUM(price) FROM products GROUP BY type"; $result = mysql_query($query) or die(mysql_error()); // Print Totals while($row = mysql_fetch_array($result)){ echo "Total ". $row['type']. " = $". $row['SUM(price)']; echo "<br />"; }
Edited by - student101 on 19 Sep 2010 13:29:51
Replied 26 Sep 2010 13:12:35
26 Sep 2010 13:12:35 Chris Trace replied:
ok
will try that out
might get back to you if still stuck
will try that out
might get back to you if still stuck
Edited by - Chris Trace on 27 Sep 2010 05:17:21
Replied 28 Sep 2010 03:44:23
28 Sep 2010 03:44:23 Chris Trace replied:
thanks for that
an easier echo statement however is
<?php echo $row_addcharsum['SUM(plussubtotal)']; ?>
cheers
an easier echo statement however is
<?php echo $row_addcharsum['SUM(plussubtotal)']; ?>
cheers