I have created a log in script that starts a session when the username and password are correct. This functions correctly but in the DB i am storing a value called EST_ID. This is the establishment id for each user. When performing queries from the site, i will use the where clause, so that the data returned corresponds only to people who are a member of the same establishment.
i.e select * from rooms where est_id = $est_id.
To do this, i am trying to return the establishment id from the database for the logged in user, and store the id as a session variable. I am a bit stuck as to how to do this. so far i have got:
Code: Select all
<?php
$query = "SELECT est_id FROM users where username = '$user'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "establishment id :{$row['est_id']} <br>";
}
session_start();
$_SESSION['est_id'] = "$result";
$myest = $_SESSION["est_id"];
echo "$myest";
?>
Can anybody shed any light on how to achieve this?
Thanks in Advance
Harry