Welcome Guest, Not a member yet? Register   Sign In
dropdown list
#1

[eluser]Unknown[/eluser]
I am new with code igniter and I dont know how to do for a dropdown list for updating my DB.
The problem is how to keep the actuel value of my categorie if I change other fields than categories. What happens is that the first categorie will overwrite the category in my DB.

in my model
public function getCategorie($aRestriction = null)
{
//$result = array();
if (is_array($aRestriction))
{
foreach ($aRestriction as $sKey => $sValue)
{
$this->db->where($sKey, $sValue);
}
}
$this->db->select('Categorie');
$query = $this->db->get('Machine');
return $query->result();
}

my controller
public function modifMachine(){

$this->load->model('model_proprio');
$proprio = $this->model_proprio->getProprio();
$cat = $this->form_model->getCategorie();//I get the category

$NoMachine = $this->uri->segment(3);
$aMachine = $this->form_model->getMachine(array('NoMachine'=>$NoMachine));
$aData['noMachine'] = $aMachine[0]->NoMachine;
$aData['categorie'] = $cat; //I put it here
$aData['marque'] = $aMachine[0]->Marque;
$aData['model'] = $aMachine[0]->Model;
$aData['noSerie'] = $aMachine[0]->NoSerie;
$aData['annee'] = $aMachine[0]->Annee;
$aData['electrecite'] = $aMachine[0]->Electrecite;
$aData['detail'] = $aMachine[0]->Detail;
$aData['dimension'] = $aMachine[0]->Dimension;
$aData['condition'] = $aMachine[0]->Condition;
$aData['prixDemande'] = $aMachine[0]->PrixDemande;
$aData['prixAffiche'] = $aMachine[0]->PrixAffiche;
$aData['listePar'] = $aMachine[0]->ListePar;
$aData['localisation'] = $aMachine[0]->Localisation;
$aData['photo_1'] = $aMachine[0]->photo_1;
$aData['photo_2'] = $aMachine[0]->photo_2;
$aData['noProprio'] = $aMachine[0]->NoProprio;
$aData['proprio'] = $proprio;

$this->load->view('modifMachine',$aData);
}
and my view
<select name='categorie'>
&lt;?php
foreach($categorie as $row)
{
echo '<option >'.$row->Categorie.'</option>';
}
?&gt;
</select>

Thanks,
Daniel
#2

[eluser]Ben Edmunds[/eluser]
Daniel,

Are you wanting to pay someone to do this for you?

If not, you might want to move this to the application dev forum...




Theme © iAndrew 2016 - Forum software by © MyBB