Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: how to add numbers from tables[SOLVED]

how to add numbers from tables[SOLVED] 19 Sep 2016 14:03 #14555

I dont know where to ask this, i have searched for days and played around with my component. I have cooked a component and would like to add the sum of the values and display at the bottom. Can anyone please send me in the right direction to learn how. Any help is greatly appreciated.
Last Edit: 19 Sep 2016 16:44 by joomlalover28469.
The administrator has disabled public write access.

Trying to find out how to add numbers from tables 19 Sep 2016 16:42 #14557

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I recommend you to place the calculation in the view.html.php file.
Write a function which take the items in parameters, and sum all the items.
Then return the result to the caller function : displayXxxxxx()
it could be something like :
$this->total = $this->sumColumn($items, 'myColumn');
Then in the template, just show the result trough this new var.

I suggest you to send the column name to sum as parameter, so if you have more than one column to sum, it can be reusable.
You can also place this function somewhere else if you want to reuse. You can place it in different places :
  • helper
  • view superclass
  • plural model superclass
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: joomlalover28469

does someone have a a component example 22 Sep 2016 16:44 #14569

i am trying to get my table to add data at the end and cannot figure out a few things and if i had an example of what to do where i could figure it out. Admin, was nice enough to help me with the reply below. I am novice at php and cannot figure out what the :displayXxxxx() means and where i should put the sumColumn object (define it?). I am sorry to bother yall, but i dont know where to turn. I thought about using codementor. The demos downloads say im not authorized Thanks for any advice.
I recommend you to place the calculation in the view.html.php file.
Write a function which take the items in parameters, and sum all the items.
Then return the result to the caller function : displayXxxxxx()
it could be something like :
$this->total = $this->sumColumn($items, 'myColumn');
Then in the template, just show the result trough this new var.

I suggest you to send the column name to sum as parameter, so if you have more than one column to sum, it can be reusable.
You can also place this function somewhere else if you want to reuse. You can place it in different places :
helper
view superclass
plural model superclass
The administrator has disabled public write access.

does someone have a a component example 23 Sep 2016 07:35 #14570

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I strongly recommend to play with the demo component. With the sample you will maybe understand better the logic.
What do you mean when you say you were not authorized ? For the demo ?

Let me explain a bit.
displayXxxx(), is the rendering View function.

'Xxxx' is the alias name of your layout. it can be displayDefault() for instance.
First, choose the correct layout page for this calculation, then edit it for achieving the calculation.
For a novice, it is the most easy. Then if you are a purist, you can place this new function in the model or somewhere else. At the moment, just try to achieve it in the view file, which is the most easy.

Todo : Take your items lists ($this->items) into a loop for summing every item value. If you really don't understand, I can help you more.

Otherwise, you can hire a developer here :
www.j-cook.pro/index.php/support/23-need-a-developper
Coding is now a piece of cake
The administrator has disabled public write access.

does someone have a a component example 24 Sep 2016 20:04 #14576

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
If you can post you zipfile for the component here, I can quickly add the stuff you want as an example :)
That way you have a good way to start, be I think you have to be aware that you need to code this in php
The administrator has disabled public write access.
The following user(s) said Thank You: joomlalover28469

does someone have a a component example 24 Sep 2016 20:17 #14577

thank you, in the estimate_cost, i just want to sum the column of the cost. i added the sample data cook. if i can see how to add the column i can do the rest. Thank you.
Last Edit: 24 Sep 2016 20:37 by joomlalover28469.
The administrator has disabled public write access.

does someone have a a component example 24 Sep 2016 20:20 #14578

it wouldnt let me add to site so i used google drive


Thanks.
Last Edit: 24 Sep 2016 20:37 by joomlalover28469.
The administrator has disabled public write access.

does someone have a a component example 24 Sep 2016 20:23 #14579

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Nice, I will see what I can do. Might take a couple of days since it's weekend and all ;)
The administrator has disabled public write access.
The following user(s) said Thank You: joomlalover28469

how to add numbers from tables[SOLVED] 24 Sep 2016 20:24 #14580

thank you, i appreciate you taking the time to help me understand. :silly:
The administrator has disabled public write access.

does someone have a a component example 24 Sep 2016 20:32 #14581

can i remove the link now, i left my email on it and it makes me nervous. sorry. i dont care if you have but i dont want it in the wild.
The administrator has disabled public write access.

how to add numbers from tables[SOLVED] 24 Sep 2016 20:40 #14582

last reply here is a link without info so it can stay up. sorry for all the replies.
Last Edit: 24 Sep 2016 20:49 by joomlalover28469.
The administrator has disabled public write access.

does someone have a a component example 24 Sep 2016 20:48 #14583

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Got it, you can remove the link
The administrator has disabled public write access.
The following user(s) said Thank You: joomlalover28469

does someone have a a component example 26 Sep 2016 08:58 #14585

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Hi,

You can download an example here: www.dropbox.com/s/a2zgrk49u0bo8cw/com_homeowners.zip?dl=0

A couple of pointers:
- I created a fork folder, what it is and what you can do with it, you can read here: www.j-cook.pro/index.php/f/forks
- To be able to install a new version generated from the builder without losing the fork folder I have changed the homeowners.xml file and added the fork folder to the "sites" section
- Keep a copy of your fork version soemwhere just to be safe ;)

I also created in the past a post on how to manage forked components:
www.j-cook.pro/index.php/support/9-codin...g-your-project#13101
The administrator has disabled public write access.
The following user(s) said Thank You: admin, joomlalover28469

does someone have a a component example 26 Sep 2016 09:13 #14586

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Thank you Romkabouter.
Your help is highly appreciated.

K++
Coding is now a piece of cake
The administrator has disabled public write access.

does someone have a a component example 26 Sep 2016 16:19 #14594

is there any way i can pay you for your time? Donation, charity anything?
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.142 seconds

Get Started