[GRLUG] Programming efficiently
Justin Denick
justin.denick at gmail.com
Tue Sep 25 15:08:35 EDT 2007
On 9/25/07, Topher <topher at wcsg.org> wrote:
>
> > A more dynamic approach might be
> > <?
> >
> > $sql="SELECT st_abrv FROM schema.table-with-st_abrv ORDER BY st_abrv;";
> >
> > So I ask, which would you prefer?
>
> I'd do something similar to three for something like states. However,
> also for something like states I'd get all the states into an array
> somewhow, whether it be by manually creating it, or generating it with
> your sql call.
If I were to put all the values of the states into an array in an included
file
$array=array(MI,{...});
<?
include "file-with-variables";
print ("<DEFANGED_select>");
foreach ($array as $value) { // $array is defined in "file-with-variables"
print (<DEFANGED_option value=$value>$value</DEFANGED_option>);
}
print ("</DEFANGED_select>");
Where are the elements of the array stored, are they held in the servers
memory, or the clients?
So if 50 clients connect, will each store their own variables, or will the
variables be stored 50 times in the server's memory?
If the latter is true, than it would make more sense to draw that array in
then free the results, rather than include the array as a variable.
Once you have it in an array you can do all sorts of things like make a
> drop list, easily mark one option item "selected", or whatever.
>
> Topher
> Manager of Internet Services
> Cornerstone University Radio
>
> ------
> perl -e 'print join "", (map({chr(hex(/usr/bin/pine))} (shift =~
> /\w{2}/g))),"\n"' \
> 4920776973682049206B6E6577204865782E00
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
>
--
In vino veritas.
[In wine there is truth.]
-- Pliny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shinobu.grlug.org/pipermail/grlug/attachments/20070925/61ab0378/attachment.htm
More information about the grlug
mailing list