Hi All,

I hope somebody can help.

I would like to make 1 large query from a mysql database. Once called I want to get whatever i want from that stored array, which is where im having trouble.

What i have so far is the following code, but each time the page reloads it is running the query again.

<?php
session_start();
ob_start();
include 'dbconnect.php';
if ($_SESSION['mainquery'] == ''){
	
	$SQL = "SELECT * FROM accounts a, callhistory c JOIN callhistory ON a.client_id = c.crm_reference WHERE date(c.timestamp_dtm) = '2011-05-17' ORDER BY c.timestamp_dtm DESC";
	$_SESSION['mainquery'] = mysql_query($SQL);
} else if ($_SESSION['mainquery'] != '') {
	
	$data = $_SESSION['mainquery'];
	
}
while ($row = mysql_fetch_array($data)){
	echo "hello";
}


?>

I think you'll want to store the array's, for example:

<?php
session_start();
ob_start();
if(isset($_SESSION['data'])) $data = $_SESSION['data'];
else {
  include 'dbconnect.php';
  $sql = "SELECT * FROM accounts a, callhistory c JOIN callhistory ON a.client_id = c.crm_reference WHERE date(c.timestamp_dtm) = '2011-05-17' ORDER BY c.timestamp_dtm DESC";
  $q = mysql_query($SQL);
  while($row = mysql_fetch_array($q)) $data[] = $row;
  $_SESSION['data'] = $data;
}
?>

(oops, forgot something).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.