CodeIgniter Forums

Full Version: How to put on View the result of my function at the controler
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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!

El Forum

[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 />'

El Forum

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

El Forum

[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

El Forum

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

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

El Forum

[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