"Geoff Berrow" <bl@ckdog.co.uk> wrote in message news:6i********************************@4ax.com...
I noticed that Message-ID: <4W*******************@news.xtra.co.nz> from
WindAndWaves contained the following:
Would your code still work if I used something else rather then a cookie?
Care to tell us what or is it a secret? We could guess all day.
here is the code I use... I did not write it, but it seems to work.... Note that each page passes on the session ID to the next....
<?php
// Establish a session
session_start();
include_once("connectDB.php");
// Initialize variables
$errormessage = "";
$sqlStart = "SELECT a.id, a.FN, a.name, a.description, a.photolink, a.regionId FROM friars a, regions b";
$sqlWhere = " WHERE (a.regionId = b.id) AND ";
$sqlEnd = " GROUP BY a.regionId, a.name ";
$humanSQL = "<UL>";
$maxrows = 50;
$snum = 1;
$sql = "";
$name = "";
$basketcount = 0;
// If no sortorder is set, initialize it to 1
if(!$sortorder){
$_SESSION["sortorder"] = 1;
}
// ADD TO TRIP
if($add){
// Add accomodation to the session with an incremented sortorder
$_SESSION["sortorder"] = $sortorder + 1;
$id = $add;
// Select DB data for accommodation to ADD and Append to Session
$sqladd = "SELECT * FROM friars WHERE id = $id";
$resultAdd = mysql_query($sqladd);
$myrowAdd = mysql_fetch_array($resultAdd);
// Get the Region Name
$regionId = $myrowAdd["regionId"];
$sqladd = "SELECT description FROM regions WHERE id = '$regionId'";
$resultAdd2 = mysql_query($sqladd);
$myrowAdd2 = mysql_fetch_array($resultAdd2);
//get name
$name = $myrowAdd["name"];
// Add name and id to the session
$_SESSION["cart"][$sortorder]["id"] = $id;
$_SESSION["cart"][$sortorder]["name"] = $name;
$_SESSION["cart"][$sortorder]["regionId"] = $myrowAdd["regionId"];
$_SESSION["cart"][$sortorder]["regiondescr"] = $myrowAdd2["description"];
$_SESSION["cart"][$sortorder]["description"] = $myrowAdd["description"];
$_SESSION["cart"][$sortorder]["photolink"] = $myrowAdd["photolink"];
$_SESSION["cart"][$sortorder]["FN"] = $myrowAdd["FN"];
// GET THE SQL back
$sql = $_SESSION["sqlr"][$snum]["sqler"];
// sql = stripslashes($HTTP_POST_VARS[sqlS]);
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
//$locationer = 'results.php?PHPSESSID='. session_id().'';
//header("Location: $locationer");
}
elseif ($HTTP_POST_VARS[regSubmit] || $HTTP_POST_VARS[advSubmit]){
// Select properties from regions for normal and advanced search...
include_once("connectDB.php");
$sql = $sqlStart;
$sql .= $sqlWhere;
if(count($search) < 1){
.......................................etc
}
if($HTTP_POST_VARS[advSubmit]) { // ADVANCED SEARCH
.......................................etc
}
<html.................><A HREF="...?add=[propertycode]&.....>......................./html>