#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    34
    Rep Power
    14
    Hi,

    I've got a search facility that interrogates an SQL database then shows the results 30 at a time. Currently, when you go to the next page of results it has to run the query all over again, because there is no way of handing the resultset to the PHP file. So I wondered if there was another way of doing it.

    I'm tempted to use mysql_fetch_array and create a multi-dimensional array full of result rows, then hand that around, but so far cannot find out how to hand a PHP array as a variable to a PHP page.

    IS this possible, or am I barking up the wrong tree? Or is there a better way of doing this?

    Perplexed,
    enigmatrix
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    You COULD do it using a POST method (I imagine that the result set would be to large to use GET.) However, I wouldn't recommend it. If you're result set contains 300 records (10 pages at 30/page) and each has 5 fields of an avg 30 bytes each, that's 45KB of information you'll be passing back and forth to the client each time you go to a new page. And you can't just drop viewed information because you might need to re-generate a previous page. If you are developing for a broadband intranet or otherwise KNOW that all users will be using broadband, then this is no problem. HOwever, for a typical web page, a 28.8K user will experience a delay of about 20 seconds for each page request just to pass this large result set each way!

    If your query is extremely complex with several joins and conditionals, you MIGHT save some time by storing it in a temporary table. If it's a simple query you're much better off just doing the query for each new page.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    34
    Rep Power
    14
    It's a good point, and one I had not considered simply because it IS on a broadband intranet. However, a resultset of 300 would actually be somewhat on the small side for most querys on this database, so I'd be carting much more than 45Kb at a time. Good job you brought it up.

    Do you know if it's possible to POST the result from an SQL query to another page? Or does the resultset get dropped the when you close the database?


    enigmatrix

  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    What we were talking about was the result set. I think you mean the result index? In that case, no. The result set the result index points to ceases to exist when the script ends.

    How often would the data change? I mean, you could run a cron job to generate static HTML pages from the query and only run it periodically.

Similar Threads

  1. different page display depending on $_GET results
    By emp/ir:kal in forum PHP Development
    Replies: 5
    Last Post: February 11th, 2004, 10:12 AM
  2. Replies: 0
    Last Post: February 8th, 2004, 10:11 PM
  3. next page for results / overflow result pages
    By virtualdub in forum PHP Development
    Replies: 3
    Last Post: February 5th, 2004, 04:15 PM
  4. POST results in BLANK HTML page
    By MO_PAshun in forum PHP Development
    Replies: 5
    Last Post: January 24th, 2004, 01:19 AM
  5. passing the url from HTML page to a php
    By lordorkus in forum PHP Development
    Replies: 10
    Last Post: January 20th, 2004, 05:36 PM

IMN logo majestic logo threadwatch logo seochat tools logo