by Marty Landman <marty(at)face2interface.com>
|
Date: |
Sat, 09 Sep 2000 20:30:02 -0400 |
To: |
hwg-languages(at)mail.hwg.org |
Cc: |
Shannon Doyle <shannon(at)bigblue.net.au> |
|
todo: View
Thread,
Original
|
|
Shannon Doyle wrote :
> What I can't seem to get my head around is how am I
> going to script the php calc/query etc based on the fact
> that the information coming from the previous page
> could be different each time it is submitted. ie, the
> names of the select fields will change.
Hi Shannon.
It's straightforward to conceptualize this once you realize that the query
itself can be expressed as a variable :
$result = mysql_query($query);
Now the thing to do is break the query into its static and variable pieces,
write routines to supply the variable parts and then compose the whole
thing into a single valid SQL statement. At least that's the way I do this
kind of thing.
For example, you may already be used to coding something like :
$query = "select a,b,c from my_Data where Key = $id;";
It's just a bit more work to then say :
$query = "select $x,$y,$z from my_Data where $field = $id;";
You could even make the table name into a variable. It's not as confusing
in my experience if you make liberal use of the command line, i.e. telnet
on *nix or ISQL on NT as a debugging aid.
For developing this in the least painless manner I recommend writing each
little piece of it at a time and verifying that it works before proceeding
to the next thing.
HTH,
Marty
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA