Jump to content

KanaTronix

New Members
  • Posts

    6
  • Joined

  • Last visited

KanaTronix's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is a logic testing case. When all ideas and logic are fully ready to use it'll be pluggable and very cool that what you are seeing. The reason I use the arrays is that form is to entertain dynamic feature adding which wouldn't need any interaction with the code directly.
  2. Thanks for tip. I know a lot about DB designs. And this design is one of the best if you could see it. The names on the array are just names not data types and thanks for reply but I managed to solve the issue with this code function add_bz($data){ $this->db->trans_start(); //print_r($data); foreach($data as $table => $sql){ for($r=0;$r<count($sql);$r++){ if($table==="business"){ $this->db->insert($table, $sql[$r]); print $id = $this->db->insert_id(); } else { $sql[$r] = array_merge($sql[$r], array('idd' => $id)); $this->db->insert($table, $sql[$r]); } } } $this->db->trans_complete(); if ($this->db->trans_status() === FALSE){print "Insert OP Fails";return FALSE;} return TRUE; }
  3. Thanks for the replies. But I have managed to fix it. it was so simple and make me wonder how stupid I am. I fix the loop and be like this foreach($nyingi as $ins => $vl){ foreach($vl as $fld => $box){ $uwazi = $this->input->post($box); if(is_array($uwazi) && 0<count($uwazi)){ $q=0; foreach($uwazi as $bb){ $one[$ins][$q][$fld] = $bb; $q++; } } } } The inputs are from a dynamic form form with multiple dynamic fields.
  4. Hello I have this multi dimensional array which needs to be inserted to the database table. [business] => Array ( [title] => Email Marketing [URL] => email-marketing [category] => 3 [region] => 2 ) [description_] => Array ( [text] => Some desc ) [logo_] => Array ( [blob] => mainlogo.png ) [location_] => Array ( [text] => Array ( [0] => Lemara Main Office [1] => Themi branch [2] => Sinoni branch ) [priority] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) [photo_] => Array ( [path] => Array ( [0] => lemaraphoto.png [1] => themiphoto.png [2] => sinoniphoto.png ) ) [video_] => Array ( [path] => Array ( [0] => lemaravideo.mp4 [1] => themivideo.mp4 [2] => sinonivideo.mp4 ) ) [product_] => Array ( [p_id] => Array ( [0] => product photo [1] => product 3 photo [2] => Product 2 photo ) [text] => Array ( [0] => product desc [1] => product 3 desc [2] => product 2 desc ) [expire] => Array ( [0] => product expire [1] => product 3 expire [2] => Product 2 expire ) [title] => Array ( [0] => product [1] => Product 3 [2] => Product 2 ) ) [service_] => Array ( [p_id] => Array ( [0] => Service 2 photo [1] => service 3 photo [2] => service photo ) [text] => Array ( [0] => service 2 desc [1] => service 3 desc [2] => service desc ) [expire] => Array ( [0] => Service 2 expire [1] => service 3 expire [2] => service expire ) [title] => Array ( [0] => Service 2 [1] => service 3 [2] => service ) ) ) That's the data. The database table, the table field and the corresponding value to be inserted in to the database. I'm using CodeIgniter any help would be appreciated. I have managed to make it wotk in this format [[business] => Array ( [title] => Email Marketing [URL] => email-marketing [category] => 3 [region] => 2 ) [description_] => Array ( [text] => Some desc ) [logo_] => Array ( [blob] => mainlogo.png ) ] I used this code to do it function add_bz($data){ $this->db->trans_start(); $er=0; foreach($data as $table => $sql){ if($table==="business"){ $this->db->insert($table, $sql); $id = $this->db->insert_id(); } else { array_merge($sql, array('idd' => $id)); $this->db->insert($table, $sql);} } $this->db->trans_complete(); if ($this->db->trans_status() === FALSE){print "Transaction Fails";return FALSE;} return TRUE; } Thanks in advance.
  5. Any input is deeply appreciated. What I want to get is what's important if you have an idea just write man.
  6. Hey guys. I am creating an application that require dynamic fields generated by javascript. I have managed to create the forms the database and pretty much may things. I come to hit a roadblock with this array problem. I am trying to get the data from the browser by checking which one contain more than one value and then transverses through another array this one $nyingi = [ 'location_' => ['text' => 'loc_txt','priority' => 'loc_order'], 'photo_' => ['path' => 'p_txt'], 'video_' => ['path' => 'v_txt'], 'product_' => ['p_id' => 'pt_q', 'text' => 'pt_txt', 'expire' => 'pt_xpr', 'title' => 'pt_tt'], 'service_' => ['p_id' => 'st_q', 'text' => 'st_txt', 'expire' => 'st_xpr', 'title' => 'st_tt'], 'hours_' => ['time1' => 't1', 'time2' => 't2', 'type' => 'tt'], 'map_' => ['text' => 'm_txt'] ]; use this loop foreach($nyingi as $ins => $vl){ foreach($vl as $fld => $box){ $uwazi = $this->input->post($box); if(is_array($uwazi) && 1<count($uwazi)){ foreach($uwazi as $bb){ $one[$ins][$fld][] = $bb; } } } } and get this result Array ( [location_] => Array ( [text] => Array ( [0] => Main Office [1] => Branch 1 [2] => Branch 2 ) [priority] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) [photo_] => Array ( [path] => Array ( [0] => Photo 1 [1] => Photo 2 [2] => Photo 3 ) ) [video_] => Array ( [path] => Array ( [0] => Video 1 [1] => Video 2 [2] => Video 3 ) ) what I want to get is this Array ( [location_] => Array ( [text] => Main Office [priority] => 1 ) [photo_] => Array ( [path] => Photo 1 ) [video_] => Array ( [path] => Video 1 ) [product_] => Array ( [p_id] =>Product 2 photo [text] => Product 2 Description [expire] => Product 2 expire [title] => Product 2 ) ) ) for each one of those. Any ideas where I am getting wrong.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.