hi all
my controller look like this
public function actionGetSensorsData($tractionId,$sDate,$eDate)
{
$result = array();
header('Content-Type: application/json; charset="UTF-8"');
// get all sensors
$sensorsIds=Sensor::model()->findAllBySql('SELECT sens_id FROM lead where node_id="'.$tractionId.'";');
foreach ($sensorsIds as $s)
{
$sResult = array();
$modelSensors = SensorInfo::model()->findAllBySql('SELECT * FROM information_sens where sens_id= "'.$s['sens_id'].'" and
"'.$sDate.'" <= information_sens_time and
information_sens_time <= "'.$eDate.'"
order by information_sens_temps ASC;');
foreach($modelSensors as $res){
$sResult[] = array(($res['information_sens_temps']),intval($res['information_sens_value']));
}
$data= array('data'=>$sResult);
$name = array('name'=>$s['sens_id']);
$result[]=array('name'=>$s['sens_id'],'data'=>$sResult);
}
$json = CJSON::encode($result);
echo $json ;
Yii::app()->end();
}
this contoller give as output
[{"name":"sensor_1","data":[["2012-12-01 15:00:00.070",45],["2012-12-01 15:00:00.281",95],["2012-12-01 15:00:00.883",104] ........]}]
I use this output with higcharts y ajax call to draw the graph.
Now I want to use the same output to display this data in a table format .
how can I achieve this, and how I get this json again ? usualy I use a simple code
<tbody>
<?php if(count($modelSensors)>=1) {
foreach($modelSensors as $models) : ?>
<tr>
<td> <?php echo $models['information_sens_id'] ; ?> </td>
<td> <?php echo $models['information_sens_time'] ; ?> </td>
<td> <?php echo $models['information_sens_value'] ; ?> </td>
<td> <?php echo $models['sens_id'] ; ?> </td>
</tr>
<?php endforeach;
}else {?>
<tr>
<td colspan='2' style="text-align:center;">Sorry no history found for this Node</td>
</tr>
<?php } ?>
</tbody>
but I cant pass the start date and the end date to fetch the corresponding data? should make separate method for my table?
I know is not really a yii issue
but I count on your kindness
many thanks !