Looped INSERT

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stever
Forum Newbie
Posts: 2
Joined: Sun Feb 07, 2010 10:36 pm

Looped INSERT

Post by stever »

Trying to use a "for" loop to insert into database,

$A1 = $_POST[A1];
$B1 = $_POST[B2];
$A2 = $_POST[A2];
$B2 = $_POST[B2];
$num = $_POST[number];

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

$res = mysqli->query("insert into table ('".$A[$i]."','".$B[$i]."')");

}

What am i doing wrong?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Looped INSERT

Post by papa »

Um, parse error?

Code: Select all

 
$A1 = $_POST['A1'];
$B1 = $_POST['B2'];
$A2 = $_POST['A2'];
$B2 = $_POST['B2'];
$num = $_POST['number'];
 
for ($i=0; $i<=$num; $i++) {
 
$res = mysqli->query("insert into table ('".$A[$i]."','".$B[$i]."')");
}
It still doesn't make sense. How does your $_POST array look like?
Post Reply