|
Posted by Colin Ross on 03/29/05 13:22
What I did in a situation like this (much more complicated though,
with nested select boxes in a form) was use a database, and then
created a php-created javascript file.
The javascript file was buffered, and then cached (saved to a file)
with a timestamp...
So, I can limit the amount of times the WHOLE SCRIPT is run , say once
every 24 hours at most. Also, If i just updated it, I can delete the
cached version, and a new one is made.
Sure, the script is slow... but page loads are fast becuase (unless
its NEEDED) all thats to be processed is a file-read call and such...
not (potentially) hundreds of DB queries.
If you want I can post an example... let me know.
Colin
On Tue, 29 Mar 2005 11:59:23 +0200, Merlin <news.groups@web.de> wrote:
> Hi there,
>
> I would like to save some db power by putting values into a file which are often
> used. They basicly populate a select field.
> So I placed those values into associative arrays:
> $code[language] = array("1"=> "php", "2"=> "asp");
>
> Now I would like to sort those for displaying after my preference, not by lets
> say alphabet. The easiest thing I could think of, is just to move the entry:
> $code[language] = array("2"=> "asp", "1"=> "php");
>
> But this of course does not work. I would like to be able to place values later
> on inbetween. So if somebody comes up with a language called ".net" :-) I would
> like to place it in the middle, but I cant get it to work like that :-(
>
> To build the select box I use following code:
>
> <select name="education">
> <option value ="0" selected>---</option>
> ';
> ################################################
> # build the select field
> for ($i=1; $i <= count($code[education]); $i++){
> if ($education)
> $isselected = ($i == $education) ? " selected" : ""; // select the
> active row
> else
> $isselected = FALSE;
> printf ("<option value =\"%s\"%s>%s</option>\n", $i, $isselected,
> $code[education][$i]);
> };
> ################################################
> echo'
> </select>
>
> Has anybody an idea which could help me on that? Thank you for any help.
>
> Merlin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
[Back to original message]
|