X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E10C4D1B8CA for ; Mon, 22 Dec 2003 17:07:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 47906-10 for ; Mon, 22 Dec 2003 13:07:03 -0400 (AST) Received: from mck.abak.info.pl (host-213-25-17-172.olsztyn.mm.pl [213.25.17.172]) by svr1.postgresql.org (Postfix) with ESMTP id 01067D1B491 for ; Mon, 22 Dec 2003 13:06:27 -0400 (AST) Received: from mail by mck.abak.info.pl with scanned-mks (ABAK.info.pl Secure SMTP) id 1AYTVc-0003ap-00 for ; Mon, 22 Dec 2003 18:06:21 +0100 Received: from net.wmbr.com.pl ([195.116.72.86] helo=panoramix) by mck.abak.info.pl with asmtp (ABAK.info.pl Secure SMTP) id 1AYTVc-0003aj-00; Mon, 22 Dec 2003 18:06:20 +0100 Content-Type: text/plain; charset="iso-8859-2" From: Mariusz Pekala To: pgsql-php@postgresql.org Subject: Re: Interactive querys Date: Mon, 22 Dec 2003 18:02:24 +0100 User-Agent: KMail/1.4.3 References: <1072090005426.ew11.ripley@gazeta.pl> In-Reply-To: <1072090005426.ew11.ripley@gazeta.pl> Cc: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200312221803.55855.skoot@qi.pl> X-Virus-Scanned: by mks_vir for linux X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/64 X-Sequence-Number: 2510 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The idea is nice. I am using similiar technique in my work, but you commite= d=20 some mistakes in the code. It may cause some anger/frustration amongst newb= ie=20 ones. :-) ripley@gazeta.pl (pon 22. grudzie=F1 2003 11:46): > ------ Wiadomo=B6=E6 oryginalna ------ > Od: =C2ngelo Marcos Rigo > Data: 2003-12-15 14:23 > > Temat: Re: [PHP] Interactive querys [...] > 2. Second - you have only to build your query string - using > conditions "if..." : > > start with: > > $query_str =3D "select "; > > if ($_POST["id_chbox"] =3D 1) It sets the value of possibly non-existing $_POST["id_chbox"] to 1, that=20 expression is evaluated as TRUE, thus the following is always executed. > $query_str +=3D $_POST["id_chbox"]; You, probably, wanted to say: $query_str .=3D ' id'; > if ($_POST["name_chbox"] =3D 1) > $query_str +=3D ", ".$_POST["id_name"]; Same here... =3D=3D instead of =3D, and .=3D instead of +=3D and ' name' in= stead of=20 $_POST['id_name']; Also, real code should check whether any field has been already inserted in= =20 the $query_str before the comma will be used as separator. > .............. > > and so on > > You can also try to make this script "universal" by using iterations > through $_POST variables - its possible to write something like > > for ($n=3D0; n < ...;$n++) > { > $_POST[$cols[$n]."_chbox"]............ > } > > The only minus of this method is that it can take some time :) A few dozens of iterations should be pretty fast. And this method is more= =20 'elegant' than linear - if( x=3D=3D1)... else if( x=3D=3D2) ... else if( x= =3D=3D3).. way. > > I hope it helps > Asia Sledzik Me too... ;-) Mariusz - --=20 [http://skoot.qi.pl for GPG keys] "A computer programmer is someone who, when told to "Go to Hell", sees the "Go to", rather than the destination, as harmful." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/5yOxvkWo15WV1rkRArQUAJ9Yg6hjGUSrDjq665TpX6Wfe/X3YwCfU0vh 3Lpd8mZ51K6AvnqUax7B1zs=3D =3D+pJE -----END PGP SIGNATURE-----