This is weird... to me
Posted: Tue Aug 25, 2009 2:32 am
Hi,
I'm trying to add this multidimensional array to my database. I've got a multidimensional array called $items. For this example, I have two items in $items, just to make it simple.
As you'll notice, I've got two variables called $player and $id. When I set these to for example $player = "test"; and $id = "blabla"; it adds two rows to the database, as it should. But when I use the code below, it only adds one row. Why does it only recognize one item, instead of both? I've tried to echo $player, and it shows the correct item. Both of them. So, apparently they're both there, but it just won't add both to the database.
$j = 0;
while($j < count($items)){
$player = $items[$j]['name'];
$id = $items[$j]['id'];
$status = "none";
mysql_query("INSERT INTO css1_css (name,id,status) VALUES('$player','$id','$status')");
$j++;
}
I'm trying to add this multidimensional array to my database. I've got a multidimensional array called $items. For this example, I have two items in $items, just to make it simple.
As you'll notice, I've got two variables called $player and $id. When I set these to for example $player = "test"; and $id = "blabla"; it adds two rows to the database, as it should. But when I use the code below, it only adds one row. Why does it only recognize one item, instead of both? I've tried to echo $player, and it shows the correct item. Both of them. So, apparently they're both there, but it just won't add both to the database.
$j = 0;
while($j < count($items)){
$player = $items[$j]['name'];
$id = $items[$j]['id'];
$status = "none";
mysql_query("INSERT INTO css1_css (name,id,status) VALUES('$player','$id','$status')");
$j++;
}