Welcome Guest, Not a member yet? Register   Sign In
Error with object and member of array
#1

[eluser]beecode[/eluser]
I try to get data from model by for loop from times to check.I don'know now i am correct about logics and code which I wrote. My program generate value from model initial value from 2 values that is times which recieve from input values.This is my views from.

<?php if($times>0): ?>
&lt;?php for($i=1;$i<=$times;$i++):?&gt;
<p>
<label>ช่วงที่ &lt;?php echo $i; ?&gt;ตรวจสอบตั้งแต่วันที่ </label>
&lt;input name="start_date&lt;?php echo $i; ?&gt;" id="start_date&lt;?php echo $i; ?&gt;" class="start_date times"/&gt;
<label>ถึงวันที่</label>
&lt;input name="end_date&lt;?php echo $i; ?&gt;" id="end_date&lt;?php echo $i; ?&gt;" class="end_date times" /&gt;
</p>
&lt;?php endfor; ?&gt;


Now i used 2 dimention arrays for keep data which get from models to send to view page this is my controller
for($i=1;$i<=$times;$i++){
$data['start_date'.$i] = $this->input->post('start_date'.$i);
$data['end_date'.$i] = $this->input->post('end_date'.$i);
//$start_date =1;
$start_date = $this->input->post('start_date'.$i);
$end_date = $this->input->post('end_date'.$i);

//echo $end_date.'<br />';
//$region = 'region'.$i;
$data['regions'][$i] = $this->areas_model->find_by_region($start_date,$end_date);
}
$this->areas_model->find_by_region($start_date,$end_date);

$this->load->view('charts/view_graph',$data);


This is my models.

function find_by_region($start_date,$end_date){
$sql = "SELECT `regionid` , SUM( `isa_2_area` ) AS Rai
FROM `doae_plantarea`
INNER JOIN doae_user ON ccaa_code = CONCAT( isa_1_location_provinceid, '000000' )
WHERE `isa_8_harvest_date` BETWEEN '".$start_date."' AND '".$end_date."'
GROUP BY doae_user.regionid";
$query = $this->db->query($sql);

return $query;
}


And Last view for generate graph.

<tbody>
<tr>
<th>Central region</th>
&lt;?php for($i=1;$i<=$times;$i++): ?&gt;
&lt;?php foreach($regions[$i]->result_array() as $region):?&gt;
&lt;?php
if($region['regionid']==1){
echo '<td>'.$region['Rai'].'</td>';
}
?&gt;
&lt;?php endforeach; ?&gt;
&lt;?php endfor; ?&gt;
</tr>
<tbody>


Actually now it ok for generate graph but some times I change $regions[$i]->result_array() to result() function when iterate to twice up it error about member array or object I don't know much.

Please help me for checkmy solution for performance and speed of code and SQL because I must query data from morethan 500,000 records..


Messages In This Thread
Error with object and member of array - by El Forum - 03-04-2010, 05:44 PM
Error with object and member of array - by El Forum - 03-04-2010, 07:18 PM
Error with object and member of array - by El Forum - 03-04-2010, 07:33 PM
Error with object and member of array - by El Forum - 03-04-2010, 07:34 PM
Error with object and member of array - by El Forum - 03-04-2010, 07:39 PM
Error with object and member of array - by El Forum - 03-04-2010, 07:53 PM
Error with object and member of array - by El Forum - 03-04-2010, 07:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB