Inlude select dates in json array

Questions related to using nuBuilder Forte.

Inlude select dates in json array

Unread postby GlenMcCabe » Wed Apr 21, 2021 9:45 pm

I have the following code to create an array for graphing. It lives in the before edit of the form

$a[] = ['Reason', 'Referrals'];

$sd="#start_date#";
$ed="#end_date#";

$s = "
SELECT
referral_reasons.reasonforreferral AS reason,
COUNT(referral.referralreasonsID) AS Referrals
FROM
referral
LEFT JOIN referral_reasons ON referral.referralreasonsID=referral_reasons.id
WHERE
(referral.referralDate BETWEEN '$sd' AND '$ed')
GROUP BY referral.referralreasonsID
";

$t = nuRunQuery($s);

while($r = db_fetch_row($t)){
$a[] = [$r[0], Floatval($r[1])];
}
$j = "gdata = " . json_encode($a) . ";";

nuAddJavascript($j);

I need to display the dates ( $sd $ed) as part of the graph. Can I build them into the array? Are they available within an HTLM object on the form?

Now sorted - the dates are available within the js script of the HTML object.
Last edited by GlenMcCabe on Wed Apr 21, 2021 10:06 pm, edited 1 time in total.
GlenMcCabe
 
Posts: 87
Joined: Sun Sep 29, 2019 8:10 pm

Re: Inlude select dates in json array

Unread postby GlenMcCabe » Wed Apr 21, 2021 10:05 pm

Problem sorted. I can access the dates within the js script.
GlenMcCabe
 
Posts: 87
Joined: Sun Sep 29, 2019 8:10 pm


Return to General

Who is online

Users browsing this forum: TernenceRichard and 14 guests