Question how to implement the calculations

sasha199

Member
Good afternoon, I have this question, I have two separate lists, all the data from them is written in db, how do I create a third list for calculating data from the past two? For example, output in the form how do I need the total sum of the first list and the second in the third?
 
Depends on what you need exactly.

You can use calculation elements in your third list doing mySql queries
https://fabrikar.com/forums/index.php?wiki/calculation-element/
https://fabrikar.com/forums/index.php?wiki/php-common-tasks/&redirect=common-php-tasks

You can create a MySQL view in your DB and link a Fabrik list to this view.

Hi, there are questions with running php code in the form of a list, I created a list with two standard fields id and date, add a third with the field class, insert the code in the default field, go to the page of the sheet, but not what data is not uploaded, what am I doing wrong? Please tell me?

// Get a db connection.
$myDb = JFactory::getDbo();
// Create a new query object.
$myQuery = $myDb->getQuery(true);
$myQuery
->select(array('id', 'name'))
->from('sbrh2_datebase')
->where('id = ' . $myDb->quote('value'));
// Assign the query to the db
$myDb->setQuery($myQuery);
// Load the results as an array of objects.
$rows = $myDb->loadObjectList();
$list = array();
foreach ($rows as $row)
{
$list[] = "<li>" . $row->id . " " . $row->name . "</li>";
}
return "<ol>" . implode($list) . "</ol>";
 
Not sure what you are doing and what you want to achieve.

1.The php code of a calculation element has to go into the calculation field https://fabrikar.com/forums/index.php?wiki/calculation-element/

2. What do you want to achieve with your code?
Honestly, to begin with, I wanted to figure out how to output data using a php query, and then after iterating through them to make calculations.

I have 3 tables in the database, A B C, I would like to keep the counts of Table A and B in Table C, on a separate page on the site.

b86e11807064.jpg

dfb3fab39205.jpg


8126aac97635.jpg
 
Last edited:
Which "counts"? The totals?

So do what you want in the calc.
Turn error reporting on.
Test you queries directly in phpMyAdmin (to get the total would be something like SELECT count(*) from xy)

What should
->where('id = ' . $myDb->quote('value'));
do in your example? Usually the id (in Fabrik autoincrement, integer) will never be = the string 'value')

Is the name of your table really sbrh2_datebase?
 
Which "counts"? The totals?

So do what you want in the calc.
Turn error reporting on.
Test you queries directly in phpMyAdmin (to get the total would be something like SELECT count(*) from xy)

What should
->where('id = ' . $myDb->quote('value'));
do in your example? Usually the id (in Fabrik autoincrement, integer) will never be = the string 'value')

Is the name of your table really sbrh2_datebase?

This is really the name of one of the tables, in general, I would like to unload a list of data from db in order to further use them for calculations, for example, if you write pure php, then there is a query in db, and then a search, and the positions are unloaded one after the other, here I would like to achieve the same thing, position 1 with id 1, position 2 with id 2, and so on, I checked the query, it really does not give out any data, I just want to understand where to write php to get the list of data.
 
I checked the query, it really does not give out any data
As I said
Usually the id (in Fabrik autoincrement, integer) will never be = the string 'value')
If your query should return some data you mustn't restrict it with an "impossible" WHERE condition.
 
Thanks for sharing your query.
please try this code.
class Main {
public static void main(String[] args) {

char operator;
Double number1, number2, result;

// create an object of Scanner class
Scanner input = new Scanner(System.in);

// ask users to enter operator
System.out.println("Choose an operator: +, -, *, or /");
operator = input.next().charAt(0);

// ask users to enter numbers
System.out.println("Enter first number");
number1 = input.nextDouble();

System.out.println("Enter second number");
number2 = input.nextDouble();

switch (operator) {

// performs addition between numbers
case '+':
result = number1 + number2;
System.out.println(number1 + " + " + number2 + " = " + result);
break;

// performs subtraction between numbers
case '-':
result = number1 - number2;
System.out.println(number1 + " - " + number2 + " = " + result);
break;

// performs multiplication between numbers
case '*':
result = number1 * number2;
System.out.println(number1 + " * " + number2 + " = " + result);
break;

// performs division between numbers
case '/':
result = number1 / number2;
System.out.println(number1 + " / " + number2 + " = " + result);
break;

default:
System.out.println("Invalid operator!");
break;
}

input.close();
}
}

Walgreenslistens
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top