total of field, sorted by user

maulidebo 26 Oct, 2013
hi,

first many congrats with this great joomla project.
as a newbie to chronoforms I have several questions. one is more difficult then others :-)

i'll start with this:

I made a very simple form .

give a name, a date and enter your ridden kilometers.

on another page I want to summerize the ridden kilometers per name. (step forward I want to summerize them per month, per year).

can anyone help me?
GreyHead 27 Oct, 2013
Hi maulidebo,

Id you save the form results and a user identifier to a database table then you can build a second form using the DB Multi Record Loader to show a listing.

Note that users are not very good at entering their name the same way on each visit so that may not be a good identifier!

Bob
maulidebo 28 Oct, 2013
Hi Bob,

thanks for your prompt reply. but it isn't that simple for me than I thought...

I made it so far my form works great. even with the name of the user already filled in. so the error of making mistakes there is gone.

nog the summary page:

what I want is this:

for each user the sum of field 'km'

I tried a chronoform connectivity and a normal chronoform . the result is every time empty. so no syntax error with a blanco page:

this is my code in a custom form type in chronoform:

<?

$user = &JFactory::getUser();
$db = &JFactory::getDBO();
$query = "SELECT naam, datum,  SUM(`km`) as `totaal’ FROM `mowu1_chronoforms_data_kilometervreter_bis` WHERE naam =“$user->name;

$db->setQuery($query);
$result = $db->loadObject();
$totalkm = $result->totaal;
echo "totaal afstand gereden: "$totalkm;

?>


can you help me?
GreyHead 30 Oct, 2013
Hi maulidebo,

I can see that this line has some incorrect quotes in it
$query = "SELECT naam, datum,  SUM(`km`) as `totaal’ FROM `mowu1_chronoforms_data_kilometervreter_bis` WHERE naam =“$user->name;

Please try:
$query = "
SELECT `naam`, `datum`, SUM(`km`) AS totaal
  FROM `#__chronoforms_data_kilometervreter_bis` 
  WHERE `naam` = '{$user->name}' ;
";

Bob
This topic is locked and no more replies can be posted.