That’s an easy one
you have a system_id field in each of your database tables.
eg: Bob, Mary and Jane are part of system_id 1, they can only see clients from system_id 1.
eg: David, Smith and Peter are part of system_id 2, they can only see mysql data from system_id 2, they cannot see Bob, Mary or Janes data because it’s part of system_id 1.
When a user logs in, do something like this to save their current system_id into a session variable:
// start processing the login with users login/password.
$sql = "SELECT * FROM `user` WHERE
`username` = '".mysql_real_escape_string($_POST['username'])."'
AND `password` = '".mysql_real_escape_string($_POST['password'])."'";
$res = mysql_query($sql);
$client_data = mysql_fetch_assoc($res);
if($client_data){
// user has logged in.
$_SESSION['_system_id'] = $client_data['system_id'];
}else{
echo 'Login failed or something...';
}
then each time you run a SQL query, add the system id onto the end.
//eg: look up client list for this system
$sql = "SELECT * FROM `client` WHERE system_id = '".$_SESSION['_system_id']."'";
$res = mysql_query($sql);
// etc...
$sql = "INSERT INTO `client` SET system_id = '".$_SESSION['_system_id']."' .....
there’s a few fun trickeries you’ll run into along the way, like sequential numbering per system (auto increment wont give sequential numbers per system), but the above should give you a good start into a multi-user single-database setup.
The way I do it? I have a simple database class that builds SQL queries, every UPDATE /INSERT/DELETE/SELECT SQL query gets the system_id automatically appended to it based on the currently logged in users system.
Hope that helps 