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
https://forums.phpfreaks.com/topic/102347-cache-query-results/
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
https://forums.phpfreaks.com/topic/102347-cache-query-results/#findComment-524069
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.