CodeIgniter Forums
How to put on View the result of my function at the controler - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: How to put on View the result of my function at the controler (/showthread.php?tid=26158)



How to put on View the result of my function at the controler - El Forum - 01-07-2010

[eluser]007CR[/eluser]
Happy new year 2010 !
I'm a big begnner in CI, so iti is very appreciated if someone here can help me:

I've this on the modal :
function GetLesPlusRecents($argIdThematique=0, $argDebut=0, $argFin=10){
$Sql = "select *
from experiences E
where E.FK_IdThematique = ".$argIdThematique."
order by E.DatePost asc limit ".$argDebut.",".$argFin ;
$Query = $this->db->query($Sql);
return $Query->result();
}
and in the controler :


function LesPlusRecents($argIdThematique = 0,$Page=1){
if(IsValidId($argIdThematique)){
if($Page==1){
$DebutOffset = 0;
$FinOffset = $Page*10;
}else{
$DebutOffset = (10*($Page-1))+1;
$FinOffset = $Page*10;
}
$this->data['Page'] = $Page;
$this->data['Thematique'] = $this->mdlthematique->GetById($argIdThematique);
$this->data["Experiences"] = $this->mdlthematique->GetLesPlusRecents($argIdThematique,$DebutOffset,$FinOffset);
foreach ($this->data["Experiences"] as $IdExp => $Exp) {
$this->data["Createur"][$Exp->PK_IdProbleme] = $this->mdluser->GetById($Exp->FK_IdMembreCreateur);
$this->data["Marques"][$Exp->PK_IdProbleme] = $this->mdlrelexpmarque->GetByExperienceTxt($Exp->PK_IdProbleme);
$this->data['NbReagir'][$Exp->PK_IdProbleme] = $this->mdlreponses->Compter("FK_IdProbleme = ".$Exp->PK_IdProbleme);
$this->data['NbCasSimilaire'][$Exp->PK_IdProbleme] = null;
}
//$this->debug(array($this->data));
$this->load->view('vwThematiquesLesPlusRecents',$this->data);
}
}

I don't know how to put it on a view!

Thank ou very much!


How to put on View the result of my function at the controler - El Forum - 01-07-2010

[eluser]rogierb[/eluser]
In your view vwThematiquesLesPlusRecents.php you can reference $this->data[“Experiences”] as $Experiences
Code:
//your view
//$Experiences is a database row passed from your model

echo $Experiences->FK_IdThematique . '<br />';
echo $Experiences->DatePost . '<br />'



How to put on View the result of my function at the controler - El Forum - 01-07-2010

[eluser]007CR[/eluser]
Thank you very much, i'll try it now!


How to put on View the result of my function at the controler - El Forum - 01-07-2010

[eluser]007CR[/eluser]
I've tried it but 've got error, I think I've make mistake on the "reference $this->data[“Experiences”] as $Experiences "

can u tell me the right syntax for this plz!
It's very urgent for me


How to put on View the result of my function at the controler - El Forum - 01-08-2010

[eluser]CI_avatar[/eluser]
you may try if $Experiences contain a value.

Code:
//put this in your view
print_r($Experiences);



How to put on View the result of my function at the controler - El Forum - 01-08-2010

[eluser]007CR[/eluser]
Have already test the $data on the controller and i saw the data,ive build a function debug :$this->debug(array($this->data));from this i've seen at this array the right value, now i want to put it onn the view, and i don't how to do