Re: Loop an INSERT 10 rows from a Form

From: Date: Tue, 17 Jul 2001 05:52:01 +0000
Subject: Re: Loop an INSERT 10 rows from a Form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58196@lists.php.net to get a copy of this message
Hi, if you use MySQL you're lucky, because it handles multiple record part (after VALUES) like : INSERT INTO table VALUES(...1st, row...), (...2nd, row...),(...)... If you do not use MySQL, you may look into your dbms manual whether it is supported or not. ----- Original Message ----- From: "David" <yngwie@home.com> To: <php-general@lists.php.net> Sent: 2001. július 14. 21:50 Subject: [PHP] Loop an INSERT 10 rows from a Form > The form is no problem but how do INSERT 10 ROWS with one insert > statement. I figure some kind of loop like I did with the form. > > When form is submitted: > $query = "INSERT INTO songs VALUES ('$id', > '$songname','$rating','$video', '$album_id', > '$movie')"; > $result = mysql_db_query("movies", $query); > > if ($result) { > // worked > > > > This is the form: > <form enctype="multipart/form-data" method="post" > action="<?php echo $PHP_SELF ?>"> > <? > $i = 1; > while ($i <= $songsinalbum) { > ?> > > <TR> > <TD align="right">ID: </TD><TD><input type=text name=id > value=<? echo > $i; ?> size=3><br></TD> > <TD align="right">Songname: </TD><TD><input type=text > name='songname' > size=30><br></TD> > <TD align="right">Rating: </TD><TD><input type=text > name='rating' > value='***' size=5 maxsize=5><br></TD> > <TD align="right">Video ID: </TD><TD><input type=text > name='video' > size=2 maxsize=3><br></TD> > <TD align="right">Album ID: </TD><TD><input type=text > name='album_id' > value=<? echo $id; ?> size=2 maxsize=3><br></TD> > <TD align="right">Movie ID: </TD><TD><input type=text > name='movie' > size=2 maxsize=3><br></TD></TR> > > <? > $i++; > }; > > ?> > <input type="submit" name="submit" value="Upload"> > </form> > </TABLE> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#58196) next »