xiao Posted April 22, 2008 Share Posted April 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 22, 2008 Share Posted April 22, 2008 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()); Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 If you wanted to do it that way: $_SESSION['qryName'] = mysql_fetch_assoc(mysql_query("SELECT ...")); Or you could use a real caching system. Go look around PEAR's repos and find it. I forgot the name of the package. Quote Link to comment Share on other sites More sharing options...
xiao Posted April 22, 2008 Author Share Posted April 22, 2008 is there some caching method I can use when I can't access the PHP installation stuff? Quote Link to comment Share on other sites More sharing options...
xiao Posted April 22, 2008 Author Share Posted April 22, 2008 nobody knows an easy method of caching query results in php? Without altering the PHP installation (since I don't have access to it) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.