0

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";
}


?>
2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by twiss
0

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).

Edited by twiss: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.