Forum Moderators: coopster
<?php
session_start();
$_SESSION['some_name'] = (!empty($_POST['some_other_name']))? $_POST['some_other_name'] : FALSE;
// All your form stuff etc
?>
$_SESSION['row_rsMap'] = mysql_fetch_assoc($rsMap);
while($_SESSION['row_rsMap'] = mysql_fetch_assoc($rsMap)) {
echo $_SESSION['dot_x'];
echo $_SESSION['dot_y'];
}
$_SESSION['rsMap'] = $rsMap;
while($_SESSION['row_rsMap'] = mysql_fetch_assoc($_SESSION['rsMap'])) {
echo $_SESSION['dot_x'];
echo $_SESSION['dot_y'];
}
while($_SESSION['row_rsMap'] = mysql_fetch_assoc($rsMap)) {
echo $_SESSION['dot_x'];
echo $_SESSION['dot_y'];
}
echo $_SESSION['row_rsMap']['dot_x'];
echo $_SESSION['row_rsMap']['dot_y'];
every variable that is originally declared in the main file, but is then used in the secondary file, would need to be part of a SESSION variable.
$_SESSION['rsMap'] = ($rsMap);
while($_SESSION['row_rsMap'] = mysql_fetch_assoc($_SESSION['rsMap'])) {
echo $_SESSION['row_rsMap']['dot_x'];
echo $_SESSION['row_rsMap']['dot_y'];
}
while($_SESSION['row_rsMap'] = mysql_fetch_assoc($rsMap)) {
echo $_SESSION['row_rsMap']['dot_x'];
echo $_SESSION['row_rsMap']['dot_y'];
}
$_SESSION['rsMap'] = ($rsMap);
unset($_SESSION['rsMap']);
<?php
session_start();
// Database Connection
require_once('Connections/dbFeedback.php');
// Dreamweaver Recordset Script
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_dbFeedback, $dbFeedback);
$query_rsFeedback = "SELECT * FROM feedback";
$rsFeedback = mysql_query($query_rsFeedback, $dbFeedback) or die(mysql_error());
$row_rsFeedback = mysql_fetch_assoc($rsFeedback);
$totalRows_rsFeedback = mysql_num_rows($rsFeedback);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$_SESSION['rsFeedback'] = $rsFeedback;
$_SESSION['row_rsFeedback'] = mysql_fetch_assoc($rsFeedback);
$_SESSION['title'] = $row_rsFeedback['title'];
$_SESSION['author_name'] = $row_rsFeedback['author_name'];
?>
<a href="session_test.php">Session Test</a>
</body>
</html>
<?php
mysql_free_result($rsFeedback);
?>
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Session Test</title>
</head>
<body>
<?php
while ($_SESSION['row_rsFeedback'] = mysql_fetch_assoc($_SESSION['rsFeedback'])) {
echo $_SESSION['title'];
echo $_SESSION['author_name'];
}
?>
</body>
</html>
section of my third query that provides details about each city.... ORDER BY '$proximity' ...
$current_x = 13;
$current_y = 42; // These are ofcourse dynamic, user input etc.
// Strongly suggest checking with is_numeric()
$sql = QUERY_THREE_HERE;
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
$sql_res = array();
for($i = 0; $i < $rows; $i++) {
$loc_x = mysql_result($result, $i, "x_axis");
$loc_y = mysql_result($result, $i, "y_axis");
$distance_x = abs($loc_x - $current_x);
$distance_y = abs($loc_y - $current_y);
$distance = sqrt(pow($distance_x, 2) + pow($distance_y, 2));
$loc = mysql_result($result, $i, "location_id");
$sql_res[$loc] = $distance;
}
asort($sql_res); /* You may need to use arsort() here instead of asort(), not sure */
foreach($sql_res as $loc => $distance) {
$sql = 'SELECT some_columns FROM some_table WHERE location_id = "' . $loc . '" LIMIT 1';
$result = mysql_query($sql);
// Build your table etc here
}