Re: form question
| From: | Ryan Adams | Date: | Thu, 20 Jul 2000 16:50:23 +0000 |
| Subject: | Re: form question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7443@lists.php.net to get a copy of this message | ||
I've found that passing a field list is the safest way to get what
you want. The fact that checkboxes are undefined rather than empty
set if they're not checked kind of irks me - it disallows a lot of neat
tricks with arrays and such... ah well...
I like to use routines such as
$a_fields = explode (", ", $fieldlist); // make array of field list
while (list ($k, $v) = each ($a_fields)) {
$h_fields[$v] = $$v; // if you put this in a function, globalize $$v
}
// insert query
$fl = implode (", ", array_keys ($h_fields));
$vl = "\"".implode ("\", \"", array_values
($h_fields))."\"";
$q_insert = "insert into tablename ($fl) values ($vl)";
// update query
while (list ($k, $v) = each ($h_fields)) {
$aul[] = "$k=\"$v\"";
}
$ul = implode (", ", $aul);
$q_update = "update tablename set $ul";
to manage the queries on the other end.
Hope this helps,
Ryan
On Tue, Jul 18, 2000 at 03:42:24PM -0300, Martin A. Marques wrote:
> I have a form that calls another php script, and I need to know which
> variables the form passed to the new script to make a new query.
>
> Any idea?
>
> --
> "And I'm happy, because you make me feel good, about me." - Melvin Udall
> -----------------------------------------------------------------
> Martín Marqués email: martin@math.unl.edu.ar
> Santa Fe - Argentina http://math.unl.edu.ar/~martin/
> Administrador de sistemas en math.unl.edu.ar
> -----------------------------------------------------------------
>
> --
> 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
---end quoted text---