Jump to content

Passing function data to html table function


thenorman138

Recommended Posts

I have two functions, one loading data and the other loading the data into an html table. I've done this for 3 other data sets without issue but this one is not loading into the table for some reason. The html table loads but it's empty. I have error printing on but there are no errors. Also the query returns the correct results when I manually run it so I know it's getting results, plus it's printing the result resource ID.
 
So my result prints, and my html table shows up, but the results are not in the table so I'm assuming maybe I'm not passing it to the table properly?
 
Any guidance here is greatly appreciated
 

//Function to gather data
private function loadActivity($cust) 
{ 


$this->dbConnect();


//loading set data values from top of function file
$fromC = $this->cy_from;
$fromP = $this->py_from;
$thruC = $this->cy_thru;
$thruP = $this->py_thru;
$endYr = $this->py_endYr;


$query = "
select count(*), 'PRIOR' as Range
from actvty
where cust = {$cust}
AND date between '{$fromP}' and '{$thruP}'
union all
select count(*), 'CURRENT' as Range
from actvty
where cust = {$cust}
AND date between '{$fromC}' and '{$thruC}'
union ALL
select count(*), 'FULL' as Range
from actvty
where cust = {$cust}
AND date between '{$fromP}' and '{$endYr}'";


$result = odbc_exec($this->ocon,$query);
print_r($result); //This prints "Resource ID #76"
$this->activitySum = array();
if ($result) {
while ($row = odbc_fetch_array($result)) {
$this->activitySum[$row['Range']];
$this->isloaded = true;
} 
}else{
echo"query failed" . odbc_error();
}
}


public function getCallActivityHTMLcust($cust, $header='Activity'){


$this->loadActivity($cust);


$h2 = "<table class='customer-table'>";
$h2 .= "<thead><tr><th colspan='2' style='font-weight: bold'></th>" . htmlspecialchars($header) . "</tr></thead>";
$h2 .= "<tbody>";
$h2 .= "<tr><td>{$this->pyyy} YTD</td><td style='text-align: right;'>" . $this->activitySum['PRIOR'] . "</td></tr>";
$h2 .= "<tr><td>{$this->yyyy} YTD</td><td style='text-align: right;'>" . $this->activitySum['CURRENT'] . "</td></tr>";
$h2 .= "<tr><td>{$this->pyyy} Full Year</td><td style='text-align: right;'>" . $this->activitySum['FULL'] . "</td></tr>";
$h2 .= "</tbody></table>";


return $h2;
}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.