thanks for the reply.
Yes, I realize I'm just storing the id#. My assumption is that the result set persists across page requests, and all I have to do is keep using the id# to access it. However, I'm beginning to believe that as soon as the page is left, even just to go back to itself, the result set fades away.
Here's the code for your edification. Note, the include of "common.php" holds the session_start() call. The get_ad_recordset() function runs the first time the page is called, then is skipped on subsequent calls.
<?php
include "common.php";
html_header();
if($_REQUEST['run'] == "") get_ad_recordset();
else show_ads($_REQUEST['screen']);
function get_ad_recordset()
{
//Query the database for all ads
switch($_REQUEST['as'])
{
case 1: $ad_section = '1961 Tempest Parts List';
break;
case 2: $ad_section = '1962 Tempest/LeMans Parts List';
break;
case 3: $ad_section = '1963 Tempest/LeMans Parts List';
break;
case 4: $ad_section = 'Pontiac (non 61-63 Tempest/LeMans) Parts List';
break;
case 5: $ad_section = 'Non-Pontiac Car-Related Parts List';
break;
case 6: $ad_section = 'Manuals and Literature List';
break;
case 7: $ad_section = 'Memorabilia and Collectibles List';
break;
case 8: $ad_section = 'Tools, Equipment and Shop Items List';
break;
case 9: $ad_section = 'Members "Stuff for Sale" List';
break;
default: $ad_section = '';
break;
}
$link_id = db_connect();
if(empty($ad_section))
$query = "SELECT * FROM advertisement";
else
$query = "SELECT * FROM advertisement WHERE adSection = '$ad_section'";
$_SESSION['result'] = mysql_query($query);
mysql_close($link_id);
$_SESSION['thing'] = 5; //debug variable
if($_SESSION['result']) @show_ads();
else query_fail();
}
function show_ads($screen)
{
echo $_SESSION['result']; //debug statement
echo $_SESSION['thing']; //debug statement
if (!isset($screen)) {
$screen = 1;
echo "Unset"; //debug statement
}
//$start = $screen * $rows_per_page;
//$query = "SELECT * FROM advertisement ";
//$query .= "LIMIT $start, $rows_per_page";
$rows_per_page = 10;
$rows = mysql_num_rows($_SESSION['result']);
$pages = ceil($rows / $rows_per_page);
$last_page = $rows % $rows_per_page;
if($screen != $pages) {
for ($i = 0; $i < $rows_per_page; $i++) {
$description = mysql_result($_SESSION['result'], $i, 0);
echo "\$description = $description<br>\n";
}
}
else {
for($i=0; $i < $last_page; $i++) {
$description = mysql_result($_SESSION['result'], $i, 0);
echo "\$description = $description<br>\n";
}
}
//next two lines commented for debugging purposes i.e. reduce
//the number of "variables" that could be screwing me up.
//if($screen != $pages)
//$flag = mysql_data_seek($_SESSION['result'], ($rows_per_page + 1));
echo "<p><hr></p>\n";
// let's create the dynamic links now
if ($screen > 1) {
$url = $_SERVER['PHP_SELF'] . "?run=no&screen=" . ($screen - 1);
echo "<a href=\"$url\">Previous</a>\n";
}
// page numbering links now
for ($i = 1; $i <= $pages; $i++) {
$url = $_SERVER['PHP_SELF'] . "?run=no&screen=" . $i;
echo " | <a href=\"$url\">$i</a> | ";
}
if ($screen < $pages) {
$url = $_SERVER['PHP_SELF'] . "?run=no&screen=" . ($screen + 1);
echo "<a href=\"$url\">Next</a>\n";
}
}
?>