You are here: Re: Dynamic Form Update « PHP Programming Language « IT news, forums, messages
Re: Dynamic Form Update

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация