Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Zapis do bazy formularza.
pawel06281990
post
Post #1





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Witam,

W jaki sposób zapisać taki rząd formularza do bazy.

(IMG:https://i.ibb.co/m4hYRyv/Przechwytywanie.png)

Zacząłem robić pętlę w array ale nie zapisuje mi tak jak ja chce


  1. $sektor = esc_sql($_POST['img_sektort']);
  2. $rzad = esc_sql($_POST['img_rzad']);
  3. $coords = esc_sql($_POST['img_coords']);
  4. $url = esc_sql($_POST['img_href']);
  5. $alt = esc_sql($_POST['img_alt']);
  6. $shape = esc_sql($_POST['img_shape']);
  7. $wartość = [
  8. 'sektor'=> $sektor,
  9. 'rzad'=>$rzad,
  10. 'coords'=>$coords,
  11. 'url'=>$url,
  12. 'alt' =>$alt,
  13. 'shape' =>$shape];
  14. foreach ($wartość as $data ){
  15.  
  16.  
  17. $wpdb->insert($wpdb->prefix.'generator_map', array('sektor'=> $data['sektor'], 'rzad'=> $data['rzad'], 'coords'=> $data['coords'], 'url'=> $data['url'], 'alt' =>$data['alt'], 'shape' => $data['shape'] ));
  18. }


I nie mogę zrobić żeby mi się zapisywało wedle tego co podaje przez $_POST.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
pawel06281990
post
Post #2





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Tak wygląda formularz w js
[JAVASCRIPT] pobierz, plaintext
  1. function gui_addArea(id) {
  2. //var id = props.length;
  3. //id = 1;
  4. props[id] = document.createElement('DIV');
  5. document.getElementById('form_container').appendChild(props[id]);
  6.  
  7. props[id].id = 'img_area_' + id;
  8. props[id].aid = id;
  9. props[id].className = 'img_area';
  10. //hook ROW event handlers
  11. myimgmap.addEvent(props[id], 'mouseover', gui_row_mouseover);
  12. myimgmap.addEvent(props[id], 'mouseout', gui_row_mouseout);
  13. myimgmap.addEvent(props[id], 'click', gui_row_click);
  14. var temp = '<input type="text" name="img_id" class="img_id" value="' + id + '" readonly="1"/>';
  15. //temp+= '<input type="checkbox" name="img_active" class="img_active" id="img_active_'+id+'" value="'+id+'">';
  16. //could be checkbox in the future
  17. temp+= '<input type="radio" name="img_active" class="img_active" id="img_active_'+id+'" value="'+id+'">';
  18. temp+= '<select name="img_shape" class="img_shape">';
  19. temp+= '<option value="rect">rectangle</option>';
  20. if (document.getElementById('dd_output').value != 'css') {
  21. temp+= '<option value="circle">circle</option>';
  22. temp+= '<option value="poly">polygon</option>';
  23. temp+= '<option value="bezier1">bezier</option>';
  24. }
  25. temp+= '</select>';
  26. temp+= 'Współrzędne: <input type="text" name="img_coords" class="img_coords" value="">';
  27. temp+= 'URL: <input type="text" name="img_href" class="img_href" value="#">';
  28. temp+= 'Alt: <input type="text" name="img_alt" class="img_alt" value="">';
  29. temp+= 'Sektor: <input type="text" name="img_sektor" class="img_sektor" value="">';
  30. temp+= 'Rząd <input type="text" name="img_rzad" class="img_rzad" value="">';
  31.  
  32. //temp+= 'Sektor <select name="img_sektor" class="img_target">';
  33.  
  34. //temp+= '<option value="">&lt;not set&gt;</option>';
  35.  
  36. //temp+= '<option value="_self" >this window</option>';
  37. //temp+= '<option value="_blank" >new window</option>';
  38. //temp+= '<option value="_top" >top window</option>';
  39. //temp+= '</select>';
  40. props[id].innerHTML = temp;
  41. //hook more event handlers to individual inputs
  42.  
  43. myimgmap.addEvent(props[id].getElementsByTagName('input')[1], 'keydown', gui_cb_keydown);
  44. myimgmap.addEvent(props[id].getElementsByTagName('input')[2], 'keydown', gui_coords_keydown);
  45. myimgmap.addEvent(props[id].getElementsByTagName('input')[2], 'change', gui_input_change);
  46. myimgmap.addEvent(props[id].getElementsByTagName('input')[3], 'change', gui_input_change);
  47. myimgmap.addEvent(props[id].getElementsByTagName('input')[4], 'change', gui_input_change);
  48. myimgmap.addEvent(props[id].getElementsByTagName('select')[0], 'change', gui_input_change);
  49. //myimgmap.addEvent(props[id].getElementsByTagName('select')[1], 'change', gui_input_change);
  50. if (myimgmap.isSafari) {
  51. //need these for safari
  52. myimgmap.addEvent(props[id].getElementsByTagName('select')[0], 'change', gui_row_click);
  53. //myimgmap.addEvent(props[id].getElementsByTagName('select')[1], 'change', gui_row_click);
  54. }
  55. //set shape as nextshape if set
  56. if (myimgmap.nextShape) {props[id].getElementsByTagName('select')[0].value = myimgmap.nextShape;}
  57. //alert(this.props[id].parentNode.innerHTML);
  58. gui_row_select(id, true);
  59. }
[JAVASCRIPT] pobierz, plaintext


I jak wypełnię pierwsze pola w input to dodają się kolejne, bo to generator jest do map
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 5.10.2025 - 09:47