Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Dodaje te same wartości checkbox[]
--armind--
post 20.02.2014, 19:03:43
Post #1





Goście







Witam, mam do was wielką i ogromną prośbe! prosił bym o pomoc, ponieważ bawie się z tym od dłuższego czasu a potrzebuje na dzisiaj skończyć. Mam pola checkbox. I problem polega na tym że te same wartości. Ponumerowałem checkboxy - wszystkie 7 bo tyle ich mam od 1 do 7 i co się okazuje jak zaznacze checkbox z wartością 2 to dodaje wszędzie wartość 2 do bazy. A powinno być że zaznacze pole z wartością 1 to doda mi to tabeli 1 a nie wszędzie 1.

  1. public function add()
  2. {
  3. if ($this->input->post('add'))
  4. {
  5. $this->form_validation->set_rules('login', '<strong>Login</strong>', 'trim|required|xss_clean|is_unique[users.login]');
  6. $this->form_validation->set_rules('name', '<strong>Ksywa</strong>', 'trim|required|xss_clean');
  7. $this->form_validation->set_rules('password', '<strong>Hasło</strong>', 'trim|required|xss_clean|callback__html2txt');
  8. $this->form_validation->set_rules('password_confirm', '<strong>Potwierdzenie hasła</strong>', 'trim|required|xss_clean|callback__html2txt|matches[password]');
  9. $this->form_validation->set_rules('type[]', '<strong>Typ Użytkownika</strong>', 'trim|required|xss_clean');
  10. $this->form_validation->set_rules('displayed', '<strong>Wyświetlanie</strong>', 'trim|required|xss_clean');
  11. if ($this->form_validation->run() == FALSE){
  12. $data['errors'] = validation_errors();
  13. $this->load->view('presentersadd', $data);
  14. } else {
  15. $data['login'] = $this->input->post('login');
  16. $data['pass'] = md5($this->input->post('password'));
  17. $data['name'] = $this->input->post('name');
  18. $data['displayed'] = $this->input->post('displayed');
  19. $data['regards'] = $this->input->post('type[regards]');
  20. $data['online'] = $this->input->post('type[online]');
  21. $data['seasonshedule'] = $this->input->post('type[seasonshedule]');
  22. $data['kicker'] = $this->input->post('type[kicker]');
  23. $data['hitlist'] = $this->input->post('type[hitlist]');
  24. $data['info'] = $this->input->post('type[info]');
  25. $data['recruitment'] = $this->input->post('type[recruitment]');
  26. $data['news'] = $this->input->post('type[news]');
  27. $data['date'] = time();
  28. $data['type'] = 2;
  29. $this->Presenters_model->addUser($data);
  30. redirect('presenters/index');
  31. }
  32. }
  33. else
  34. $this->load->view('presentersadd');
  35. }



html jest zbędny chyba smile.gif?


Bardzo proszę was o pomoc z rozwiązaniem tego.. Pola check box to type[]
Go to the top of the page
+Quote Post
Pyton_000
post 20.02.2014, 19:47:02
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


  1. $this->input->post('type[regards]');

Zobacz co to zwraca
powinno być raczej|:
  1. $this->input->post('type')['regards'];

analogicznie pozostałe

Ten post edytował Pyton_000 20.02.2014, 19:47:24
Go to the top of the page
+Quote Post
--armind--
post 20.02.2014, 19:56:27
Post #3





Goście







Błędami sypie w ten sposób ;(
Go to the top of the page
+Quote Post
memory
post 20.02.2014, 21:19:14
Post #4





Grupa: Zarejestrowani
Postów: 616
Pomógł: 84
Dołączył: 29.11.2006
Skąd: bełchatów

Ostrzeżenie: (0%)
-----


28 linia $data['type'] = 2; a jak ma byc inaczej?
Go to the top of the page
+Quote Post
--armind--
post 21.02.2014, 00:51:41
Post #5





Goście







nie zadzialalo, prosze o pomoc. ;(
Go to the top of the page
+Quote Post
Pyton_000
post 21.02.2014, 11:16:00
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


Cytat(Pyton_000 @ 20.02.2014, 19:47:02 ) *
  1. $this->input->post('type[regards]');

Zobacz co to zwraca
...

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 18.07.2025 - 06:53