what i am trying to do is set a variable with a value from the database. on the page that makes the query i can do this:
Code: Select all
$data_query = mysql_query("SELECT id, dist FROM `" . DB_DATABASE . "`.`" . TBL_TMP . "` WHERE uid = '" . $uid . "' ORDER BY dist, name limit 1");
$total_rows = mysql_num_rows($data_query);
$remain = $total_rows%$num_per_row;
while($data = mysql_fetch_assoc($data_query)) {
$store = $res[$data['id']];
$_SESSION['instate'] = $store['state'];
echo "You live in " .$_SESSION['instate'];
}and it echos the value of the state.
then on another page i want to do this and it does not work.
Code: Select all
if (isset($_SESSION['instate'])){
echo "i know you live in ". $_SESSION['instate']."<br/>".Print_r ($_SESSION);
}
else {
echo "enter your zip code ". session_id() ."<br/>state: ".$_SESSION['instate']."<br/>".Print_r ($_SESSION);
}
Array ( ) enter your zip code 52e355bd3e5c8d33618de8c9fb65f3fc
state:
1
also if i do this on any page it carries the value from page to page. but i need the value to come from the database
Code: Select all
$_SESSION['instate'] = 'MN';