Out results to dashbaord

QuestionsOut results to dashbaord
GARY BRETT asked 3 years ago

Hi Abu, I have a query as such that I want to display in different parts of the page and not in the grid, is this possible:
SELECT
Count(L.id) AS Leads,
Sum(L.Cost) AS `Lead Cost`,
Sum(L.broker_fee) AS `Broker Fees`,
Sum(L.legal_fees) AS `Other Fees`,
Sum(L.comms) AS Commissions
FROM
tbl_lead L
INNER JOIN tbl_clients C ON L.client_id = C.client_id
WHERE
Year(L.LeadDate) = 2017

For example I could take the value of 'Leads', 'Lead Cost' etc and output into different divs withion the page the page?

4 Answers
Abu Ghufran answered 3 years ago

You can run it as independent query and echo the results where you want.

// assuming $g = new jqgrid();

$sql = "SELECT
Count(L.id) AS Leads,
Sum(L.Cost) AS `Lead Cost`,
Sum(L.broker_fee) AS `Broker Fees`,
Sum(L.legal_fees) AS `Other Fees`,
Sum(L.comms) AS Commissions
FROM
tbl_lead L
INNER JOIN tbl_clients C ON L.client_id = C.client_id
WHERE
Year(L.LeadDate) = 2017";

$rs = $g->get_one($sql);

echo $rs["Leads"];
echo $rs["Lead Cost"];

Gary answered 3 years ago

Fantastic, works prefectly thanks so much

Abu Ghufran answered 3 years ago

Please email me complete code for review.
This code does not explain much about error.

Gary answered 2 years ago

Hi Abu, not sure why but this suddenly broke and now doesn't work! To test again I used your demo 'alternate row' I added the following:

$sql = "SELECT i.id, invdate , c.name, i.note, i.total As total, i.closed
FROM invheader i INNER JOIN clients c ON c.client_id = i.client_id";

$rs = $g->get_one($sql);

<body>
<?php echo $rs["total"];?>
</body>

It throws an error which I think is caused by it not knowing where the query is now its been changed from $g->select_command = to $sql = – Couldn't execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') pg_tmp' at line 1 – SELECT count(*) as c FROM () pg_tmp

Your Answer

7 + 10 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?