Mary, Your program should not "wait" for a web user to click a link or a Submit button -- ever. There are no cpu cycles and there is no storage reserved once you finish building the web page.
Your whole program should draw a web page and exit. The user is then not wasting your time (and money) while he reads what you wrote and decides to click something. When he does click something, it will start up the same or a different program on your server from scratch, and that will create another web page, perhaps showing the next row. It is unnecessary to bring down an array of items from the database if you are going to use only one. Your program should be retrieving and displaying only one row, or enough extra to handle navigation. You should pass some sort of information along with that row so that when the user clicks for the next one, a program can retrieve and display it. Several people have offered session schemes for persisting your retrieval data during repeated calls. All are involved and some could open vulnerabilities to hacking. The database you use determines the exact syntax necessary for retrieving the "Next" row, when presented with information from the "Current" row. That information will have to go roundtrip out to the user's browser and then back in to the server for a NEW invocation of your program. Again, do not retrieve all of the rows unless you will pass them all to the user WITHOUT another trip to the server. David Luke, Systems Project Analyst DMS Enterprise Information Technology Services Building 4030, Suite 115 4050 Esplanade Way Tallahassee, Florida 32399-0950 (850) 922-7587 -----Original Message----- From: Mary Anderson [mailto:[EMAIL PROTECTED] Sent: Thursday, April 27, 2006 10:20 PM To: beginners-cgi@perl.org Subject: How to do a static variable that persists from page to page 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. The general scenario is this. I have a function which sets a value of x. I would like to have that value of x available on the next call to the function. (Like its supposed to be a static variable.) Here is what I tried: our %x sub fu{ my ($bar) = @_; our %x; if ($bar){ $x{'ABC'} = 0 } else{ $x{'ABC'} = $x{'ABC'} + 1; } print "Value = $x{'ABC'}", hr; fu(1); <push submit button> fu(0); gives Value = 0 Value = } How should I be doing this? mary anderson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>