[eluser]ludo31[/eluser]
Hello ;
I have really a big problem to understand the multiple array in php . here is my function in model and it returns $data
Code:
public function getHomme()
{
$this->db->select('id,nom,prix');
$this->db->from('chaussure');
$this->db->join('gnr_convenir', 'gnr_convenir.identifiant_chaussure = chaussure.id');
$this->db->where('identifiant_genre', 1);
$query = $this->db->get();
if($query->num_rows()>0)
{
foreach($query->result()as $row)
{
$data[] = $row;
}
return $data;
}
}
in controller I need this $data
Code:
public function gestionHomme()
{
$data['rows'] = $this->client_model->getHomme();
}
so with print_r($data); it shows that :
Code:
Array ( [rows] => Array ( [0] => stdClass Object ( [id] => 26 [nom] => rangers [prix] => 125600.00 ) [1] => stdClass Object ( [id] => 36 [nom] => catwoman [prix] => 125000.00 ) [2] => stdClass Object ( [id] => 42 [nom] => mimi ziznzin [prix] => 1542000.00 ) [3] => stdClass Object ( [id] => 46 [nom] => chausson [prix] => 125000.00 ) [4] => stdClass Object ( [id] => 47 [nom] => gege [prix] => 1250.00 ) [5] => stdClass Object ( [id] => 58 [nom] => brandeo [prix] => 126500.00 ) [6] => stdClass Object ( [id] => 62 [nom] => zonezero [prix] => 1542000.00 ) ) )
my problem is ho to get the value of id in function gestionHomme() because for example
when we pass that to view :
I need id as a parameter for model function :
Code:
$data['images']= $this->site_model->getImages($identifiant_chaussure);
Code:
$this->load->view('homme_view',$data);
and in view (remark in view we test $rows not $data :bug:
Code:
<?php if([b]$rows[/b]!=null):
foreach ($rows as $r): ?>
<h1>
<?php echo $r->id ; ?>
</h1>
and when we return in controller when we try to get the value of id :
Code:
public function gestionHomme()
{
$data['rows'] = $this->client_model->getHomme();
// don't work
//--> $identifiant_chaussure = element('id', $rows);
//or :-/
foreach($rows as $item)
{
$identifiant_chaussure = $item->id ;
}
}
thanks