Jump to content

cache query results?


xiao

Recommended Posts

I have a script which needs to execute about 20 queries in total.

It's a form with a lot of dropdown lists.

Actualy I only need to execute the queries one by one, because I don't need the next dropdown list if the previous option hasn't been selected yet.

But I do need the information from the previous queries to show them in dropdown lists (to be able to change previously selected options).

I can't execute all 20 queries everytime because it makes the page very slow.

Is there maybe a way to cache query results?

 

I tried $_SESSION['qryName'] = mysql_query("SELECT ...");

 

But that doesn't seem to work.

Link to comment
Share on other sites

First make a page that will refer to a different page, that will set up the session info:

<?php
session_start();
$_SESSION['last_querry'] = 0;
header("location:next_page.php");

Next page (after hitting the code above)

<?php
session_start();
$sql = array();
$sql[] .= "YOUR QUERY HERE";
$sql[] .= "";
$sql[] .= "";
//etc, etc, etc

$next_query = $SESSION['last_query'] + 1;
$_SESSION['last_query'] = $next_query;
mysql_query($sql[$next_query]) or die(mysql_error());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.