Hello Abu,
Is there any way to do something like this using phpgrid?
Reference : https://imgur.com/a/IcxHn7m
The 2nd column is generated by subtraction of 2 mysql commands and the 4th column is generated by subtraction of 2nd and 3rd column..
Thanks in advance.
You can perform such calculation in SQL query of select_command and map them as grid column.
e.g.
$g->select_command = “SELECT col1, (colx-coly) as col2, col3, col3-(colx-coly) as col4 FROM table”;
As they are calculated fields and not exist in table, add, edit on col2, col4 will not be doable.
Sorting and Searching is possible by dbname property. For e.g col2
$col[“name”] = “col2”;
$col[“dbname”] = “(colx-coly)”;
Its not like that,
What i’m trying to do is, as i said, the 2nd column is subtraction of 2 mysql command, they also from separate table. The command is something like this
$sqlcom = mysqli_query($conn,”SELECT sum(kg) as kg FROM table1 WHERE size='”.$i.”‘”); //$i is loop
$fetch = mysqli_fetch_assoc($sqlcom);
$kg= $fetch[‘kg’];
$sqlcom2 = mysqli_query($conn,”SELECT sum(kg) as kg FROM table2 WHERE size='”.$i.”‘”); //$i is loop
$fetch2 = mysqli_fetch_assoc($sqlcom2);
$kg2= $fetch2[‘kg’];
$kgs = $kg-$kg2;
echo ‘<td>’.$kgs.'</td>’;
then the 3rd column also from a different table (table3)
So it is like i’m collecting data from 4 separate tables with only using parameter from the loop.
Is it possible?
Thanks again.
If you want to have a read only view, then you can populate an 2d array (see link) with your custom business logic and pass to grid input.