array reference question

Y

yeti349

Hi. I have a html form that queries a database and stores the results
into @results. The query results are then displayed on a "results page"
that contains common features like sorting by column, change the number
of records displayed per page, etc... Currently, when the user clicks
on one of these features on the results page, the query parameters are
passed via url and the script is run again providing the requested
changes. My question is this: Is it possible, when the user first
submits the query form, to create an array reference (my $results_ref =
\@results; my @new_results = @$results_ref;) and then use this
reference when the results page features are clicked. Therefore
@new_results (containg @results data) will be modified? Does this make
sense? Thanks for any help...
 
J

John Bokma

Hi. I have a html form that queries a database and stores the results
into @results. The query results are then displayed on a "results page"
that contains common features like sorting by column, change the number
of records displayed per page, etc... Currently, when the user clicks
on one of these features on the results page, the query parameters are
passed via url and the script is run again providing the requested
changes. My question is this: Is it possible, when the user first
submits the query form, to create an array reference (my $results_ref =
\@results; my @new_results = @$results_ref;) and then use this
reference when the results page features are clicked. Therefore
@new_results (containg @results data) will be modified? Does this make
sense? Thanks for any help...

CGI is stateless in itself, so you have to store the result somewhere
(which might make things cumbersome). Oh, and please let the database do
the sorting, not Perl.
 
X

xhoster

Hi. I have a html form that queries a database and stores the results
into @results.

You do not. Html forms don't query databases, and they don't have
Perl-like variables to put the results in. I can more or less figure out
what you are trying to say, but you should still learn how to say it (and
think about it) properly. If you did, you would find it easier to figure
out on your own.

The query results are then displayed on a "results page"
that contains common features like sorting by column, change the number
of records displayed per page, etc...

Is the paging thing really necessary? I find that if I have 10,000 things
to show someone, the chances of them looking at all of them are pretty much
the same whether I show them 100 pages of 100 things or 1 page with 10,000
things.
Currently, when the user clicks
on one of these features on the results page, the query parameters are
passed via url and the script is run again providing the requested
changes.

Not Perl related, but you may want to check out aprilsoft, which lets the
user do paging and sorting right in the browser.

My question is this: Is it possible, when the user first
submits the query form, to create an array reference (my $results_ref =
\@results; my @new_results = @$results_ref;) and then use this
reference when the results page features are clicked.

I think that something vaguely like what you are trying to describe is
possible. See CGI::Session, for example.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top