Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.30 KB | None | 0 0
  1. Hi. I'd like to make a update for my cars through website. Funny thing is I have 4 cars:
  2. Peugeot
  3. Citroen
  4. Nissan
  5. Renault
  6.  
  7. 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?
  8.  
  9. Peugeot[works]
  10. Data which should be updated:
  11.  
  12.         if($peugeot)
  13.     {
  14.         foreach ($result as $value)
  15.         {
  16.              $value->model;
  17.              $value->Opis;
  18.              $value->year;
  19.              $value->price;
  20.         }
  21.             echo form_open('main/editupdate');
  22.             echo br(1);
  23.             echo form_hidden('idpeugeot',$value->id);
  24.             echo 'Model: ';
  25.             echo br(1);
  26.             echo form_input('modelpeugeot',$value->model);
  27.             echo br(1);
  28.             echo 'Link: ';
  29.             echo br(1);
  30.             echo form_input('linkpeugeot',$value->link);
  31.             echo br(1);
  32.             echo 'Opis: ';
  33.             echo br(1);
  34.             echo form_input('opispeugeot',$value->Opis);
  35.             echo br(1);
  36.             echo 'Rok: ';
  37.             echo br(1);
  38.             echo form_input('yearpeugeot',$value->year);
  39.             echo br(1);
  40.             echo 'Cena: ';
  41.             echo br(1);
  42.             echo form_input('pricepeugeot',$value->price);
  43.             echo br(2);
  44.             echo form_submit('peugot', 'Edytuj');
  45.             echo form_close();
  46.  
  47.     }
  48. Controller:
  49.  
  50.         $idpeugeot = $this->input->post('idpeugeot');
  51.         $idcitroen = $this->input->post('idcitroen');
  52.         $idnissan = $this->input->post('idnissan');
  53.         $idrenault = $this->input->post('idrenault');
  54.  
  55.  
  56.             $peugeot = array(
  57.                     'model' => $this->input->post('modelpeugeot'),
  58.                     'link' => $this->input->post('linkpeugeot'),
  59.                     'opis' => $this->input->post('opispeugeot'),
  60.                     'year' => $this->input->post('yearpeugeot'),
  61.                     'price' => $this->input->post('pricepeugeot')
  62.                 );
  63.  
  64. Model:
  65.  
  66.            public function editpeugeot($peugeot,$idpeugeot)
  67.        {
  68.  
  69.            $this->db->where('id', $idpeugeot);
  70.            $this->db->update('cars', $peugeot);
  71.        }
  72.  
  73.  
  74. Code for other 3 cars:
  75.  
  76.         elseif ($citroen)
  77.     {
  78.         foreach ($result as $value)
  79.         {
  80.              $value->model;
  81.              $value->Opis;
  82.              $value->year;
  83.              $value->price;
  84.         }
  85.             echo form_open('main/editupdate');
  86.             echo br(1);
  87.             echo form_hidden('idcitroen',$value->id);
  88.             echo 'Model: ';
  89.             echo br(1);
  90.             echo form_input('modelcitroen',$value->model);
  91.             echo br(1);
  92.             echo 'Link: ';
  93.             echo br(1);
  94.             echo form_input('linkcitroen',$value->link);
  95.             echo 'Opis: ';
  96.             echo br(1);
  97.             echo form_input('opiscitroen',$value->Opis);
  98.             echo br(1);
  99.             echo 'Rok: ';
  100.             echo br(1);
  101.             echo form_input('yearcitroen',$value->year);
  102.             echo br(1);
  103.             echo 'Cena: ';
  104.             echo br(1);
  105.             echo form_input('pricecitroen',$value->price);
  106.             echo br(2);
  107.             echo form_submit('citroen', 'Edytuj');
  108.             echo form_close();
  109.  
  110. Controller: `               $citroen = array(
  111.                     'model' => $this->input->post('modelcitroen'),
  112.                     'link' => $this->input->post('linkcitroen'),
  113.                     'opis' => $this->input->post('opiscitroen'),
  114.                     'year' => $this->input->post('yearcitroen'),
  115.                     'price' => $this->input->post('pricecitroen')
  116.                 );`
  117.  
  118. Model:
  119.  
  120.            public function editcitroen($citroen,$idcitroen)
  121.        {
  122.  
  123.            $this->db->where('id', $idcitroen);
  124.            $this->db->update('cxcxcx', $citroen);
  125.        }
  126.  
  127. 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