On 4/28/06, Sean Davis <[EMAIL PROTECTED]> wrote:



On 4/27/06 10:19 PM, "Mary Anderson" <[EMAIL PROTECTED]> wrote:

>
>
>
>
> Hi,
>    I have a cgi program that pulls data out of a database and stores it in
> an array ref.  I would like to display this data one row at a time.
> Unfortunately I am having difficulty getting the current index to persist
> from one page to another.  I could do this with a hidden field.  But I also
> have difficulty getting the array ref to persist once the submit button is
> pushed.

[snip]


Variables in CGI cannot be maintained between pages.  You have to redo your
database query for every page (or cache it on disk somewhere--but that is
going to be more complicate) and you are right about needing to use a hidden
field (or a cookie) to pass your index between pages.


There's no reason you can't keep the db return as part of saving
state. Just use Data::Dumper or similar, pass it as a hidden value,
and then read it in on the next page. As long as you're using POST and
not GET, you pass pretty much anything back and forth. Of course it
may make more sense to store the value on the server, although it
means keeping track of which data goes with which client. Storable
should work for that. You'll have to decide at what point keeping lots
of files around makes more sense than passing the result set back and
forth on every submit. Or you could use Dumper to store the cached
queries keyed by a unique id for each session in BDB or something.
then just pass the session id as a hidden field. There are lots of
options here.

If your goal here is just to allow scrolling and you're not doing
anything else with the form, though, it may be time to think about
some AJAX methods and shift state to the client.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to