Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hi. I'd like to make a update for my cars through website. Funny thing is I have 4 cars:
- Peugeot
- Citroen
- Nissan
- Renault
- I've done everything the same for all 4 cars, but updating works just for Peugeot [lol]. Can you take a look and tell me what's wrong?
- Peugeot[works]
- Data which should be updated:
- if($peugeot)
- {
- foreach ($result as $value)
- {
- $value->model;
- $value->Opis;
- $value->year;
- $value->price;
- }
- echo form_open('main/editupdate');
- echo br(1);
- echo form_hidden('idpeugeot',$value->id);
- echo 'Model: ';
- echo br(1);
- echo form_input('modelpeugeot',$value->model);
- echo br(1);
- echo 'Link: ';
- echo br(1);
- echo form_input('linkpeugeot',$value->link);
- echo br(1);
- echo 'Opis: ';
- echo br(1);
- echo form_input('opispeugeot',$value->Opis);
- echo br(1);
- echo 'Rok: ';
- echo br(1);
- echo form_input('yearpeugeot',$value->year);
- echo br(1);
- echo 'Cena: ';
- echo br(1);
- echo form_input('pricepeugeot',$value->price);
- echo br(2);
- echo form_submit('peugot', 'Edytuj');
- echo form_close();
- }
- Controller:
- $idpeugeot = $this->input->post('idpeugeot');
- $idcitroen = $this->input->post('idcitroen');
- $idnissan = $this->input->post('idnissan');
- $idrenault = $this->input->post('idrenault');
- $peugeot = array(
- 'model' => $this->input->post('modelpeugeot'),
- 'link' => $this->input->post('linkpeugeot'),
- 'opis' => $this->input->post('opispeugeot'),
- 'year' => $this->input->post('yearpeugeot'),
- 'price' => $this->input->post('pricepeugeot')
- );
- Model:
- public function editpeugeot($peugeot,$idpeugeot)
- {
- $this->db->where('id', $idpeugeot);
- $this->db->update('cars', $peugeot);
- }
- Code for other 3 cars:
- elseif ($citroen)
- {
- foreach ($result as $value)
- {
- $value->model;
- $value->Opis;
- $value->year;
- $value->price;
- }
- echo form_open('main/editupdate');
- echo br(1);
- echo form_hidden('idcitroen',$value->id);
- echo 'Model: ';
- echo br(1);
- echo form_input('modelcitroen',$value->model);
- echo br(1);
- echo 'Link: ';
- echo br(1);
- echo form_input('linkcitroen',$value->link);
- echo 'Opis: ';
- echo br(1);
- echo form_input('opiscitroen',$value->Opis);
- echo br(1);
- echo 'Rok: ';
- echo br(1);
- echo form_input('yearcitroen',$value->year);
- echo br(1);
- echo 'Cena: ';
- echo br(1);
- echo form_input('pricecitroen',$value->price);
- echo br(2);
- echo form_submit('citroen', 'Edytuj');
- echo form_close();
- Controller: ` $citroen = array(
- 'model' => $this->input->post('modelcitroen'),
- 'link' => $this->input->post('linkcitroen'),
- 'opis' => $this->input->post('opiscitroen'),
- 'year' => $this->input->post('yearcitroen'),
- 'price' => $this->input->post('pricecitroen')
- );`
- Model:
- public function editcitroen($citroen,$idcitroen)
- {
- $this->db->where('id', $idcitroen);
- $this->db->update('cxcxcx', $citroen);
- }
- Everything is in the same files. But everything what i've done was for peugeot first. In the next step I just copied the code from peugeot and change the variables for other cars. Thank you for help
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement