|
Posted by Peter Fox on 05/10/05 11:14
Following on from ScareCrowe's message. . .
>I do agree using form element variables as an array like id[1], id[2]
>instead of id1, id2. This way, when you go through the loop you can do
>something like this:
>$id_count = count($_POST['id']);
>for($b=0;$b<$id_count;$b++){
> mysql_query("INSERT INTO blahblah values ($_POST[id][$b],
>$_POST[qty][$b]");
>}
This is lots of inserts (or updates) when one would suffice.
INSERT INTO aTable name,address,telno VALUES ('Fred Smith', '1 High
St.','01376 515151')
So do something like this to economise on DB access
$vals = implode("','",array_values($POST));
$sql = "Insert .....values('$vals')";
(NB This isn't meant to be real working code - there are lots of issues
with it - just an illustration.)
--
PETER FOX Not the same since the bottom fell out of the bucket business
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Navigation:
[Reply to this message]
|