Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:37:29+00:00 2026-05-28T04:37:29+00:00

I’m new to post/redirect/get. I’m coding up the first real site that led me

  • 0

I’m new to post/redirect/get. I’m coding up the first real site that led me to discover the need for PRG.
So I had written and gotten working code that did the following:

1) user enters a search string

2) we search the database and find their desired search results

3) if we found their search results successfully, we alter the database -- 
   a 'frequency of lookups' -- to indicate the user searched and found what 
   he was looking for

4) then display the results he searched on

What I found was refreshing the page in the browser resulted in the user seeing his same search results again but we incremented the ‘frequency of lookup’ — the user is limited in the frequency of lookup in the database — so if the user refreshed the page too many times, they ran through their hourly ration of database lookups. That’s when I discovered Post/Redirect/Get a few days ago.

I am now going through the site and altering all pages that alter the database and display results and switching them over to PRG. Here is the new process:

1) user enters a search string

2) we search the database and find their desired search results

3) if we found their search results successfully, we alter the database -- 
   a 'frequency of lookups' -- to indicate the user searched and found 
   what he was looking for

4) PRG to a 'results' page

5) then display the results he searched on

And I ran into a problem. I need to somehow ‘pass’ their search results from step (2) above
to the new ‘results’ page in step (5) that I created to implement PRG.

So my question is — is there a ‘most common’ way to do this? In reading around I’ve seen ‘save the results in a .CSV file’ and also ‘save the database search results in the SESSION.’

I want to save the search results in the SESSION then on my ‘GET’ page I added for PRG to display the result, I’ll read the search results from the session variable and display them.

By that I mean I want to do this:

$result = mysql_query($query, $theDbServer);
$_SESSION['theSearchResults'] = $result.

Then on the ‘display’ page, read back the search results from $_SESSION[‘theSearchResults’]
and display them using:

 $result = $_SESSION['theSearchResults'];
 $row = mysql_fetch_row($result);

Is this a normal approach? And I suspect I cannot save the raw $result in a session variable like the above — but I’m also not sure how to put the $result above into the $_SESSION — how is that normally done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:37:29+00:00Added an answer on May 28, 2026 at 4:37 am

    Assuming you don’t want to have the final landing page do the querying (without decrementing their quota of course), then you’re going to need to use session.

    Saving to a CSV is not standard and wouldn’t scale very well. I would parse the results of the query into a more user-friendly form (a simple class or list or whatever you need). I’d then store the class and not the reader into the session. You’ll probably want to clear out that portion of the session when they leave the results page (especially if it’s a huge amount of data).

    This is assuming you’re using raw php. There are many frameworks with features for this exact case (you want to shuttle a piece of data from one page to the next).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.