Welcome Guest, Not a member yet? Register   Sign In
How to insert arrays into a DB using insert or insert batch
#11

[eluser]vincej[/eluser]
Insite - ok - I have a single value going in to 'name', but it is jibberish :

[code]
a:5:{i:0;s:13:"25 Piece Bag ";i:1;s:24:"Ribs Small Pack 5 Pieces";i:2;s:7:"breasts";i:3;s:26:" Whole Chicken: 6 - 8 lbs";i:4;s:26:" Ribs Large pack 20 pieces";}
[code]

what am I doing wrong now ?
#12

[eluser]InsiteFX[/eluser]
Try this:
Code:
$this->input->post(NULL, TRUE); // returns all POST items with XSS filter
#13

[eluser]vincej[/eluser]
sorry I've lost you again. The gibberish I posted was taken straight from the DB column. I'm not sure I know what you need me to do with

Code:
$this->input->post(NULL, TRUE); // returns all POST items with XSS filter
#14

[eluser]vincej[/eluser]
Sorry Insite - I've experimented and I've hit a dead end .. I really have no idea what to do next.
#15

[eluser]InsiteFX[/eluser]
Here is what you are trying to do
#16

[eluser]vincej[/eluser]
Thanks Insite - I am grateful that there are people like you who give up their experyise to help people lile me - I've learned something new today !
#17

[eluser]InsiteFX[/eluser]
No problem your welcome,

If you still have problems let me know and we can work something out to get you running.
#18

[eluser]vincej[/eluser]
Hi Insite - well I solved it !!!

In the end what I did was first count the size of the initial POST array, then increment the post indexes using a for loop. I feel quite proud of myself as this was a tricky one for a newb. I can run queries against the table which is nice. Thanks against for your hand you gave in arriving at the final solution.

Code:
function confirmed_Order(){
        $prodid =$_POST['prodid'];
$quantity = $_POST['quantity'];

        $numloops = count($_POST['prodid']);

for ($i = 0; $i < $numloops ; $i++) {

$sql ="
INSERT INTO `confirmedorder` (Prodid, quantity)
VALUES ($prodid[$i], $quantity[$i])
";
$this->db->query($sql);
}
}




Theme © iAndrew 2016 - Forum software by © MyBB