SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to pass query results to another page?

    I'm trying to pass an array containing the values of a query through a link, but it's not going to well. I have tried using serialize, but even that would look nasty in a url, plus it's way too big. Clicking on form buttons is not an option, so I'm not to sure how else I could pass it.

    Thanks

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sessions
    Saul

  3. #3
    SitePoint Member
    Join Date
    May 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    # page 1
    session_start();
    $_SESSION['your_data_variable'] = $your_array;
    
    # page 2
    session_start();
    $your_array = $_SESSION['your_data_variable'];
    You could do something like that (although that is a very very cut down basic example).

    More info at: http://www.php.net/sessions

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that was what I was looking for! A quick side question is it possible to pass a mysqli object to the session? Everytime I try it seems like it is empty or can't be used, and if I try to pass the mysqli result array, it only contains one record at a time.

  5. #5
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHP Manual
    Some types of data can not be serialized thus stored in sessions. It includes resource variables or objects with circular references (i.e. objects which passes a reference to itself to another object).
    You can store the objects (except those mentioned above), but you cannot do what you're trying to do. You must reconnect to database on every page. If you need particular data transfer to another page, read the result set to an array. Though, it's a rare situation that might require that.
    Saul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •