Re: problem with getting info from 2 tables in PHP / MySQL
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: problem with getting info from 2 tables in PHP / MySQL

From: Sergej Andrejev <SAndrejev@gmail.com>
Date: Wed Aug 03 2005 - 01:36:48 CEST

Recently I had a cource in university about DBMS and I think you should
use 3 tables rather than 2

TABLE login(user_id, username, password, school_id)

then TABLE shools(school_id, school_name, other_info)

and finaly TABLE shools(job_id, school_id, other_info)

Now you can login by selecting user from login table like this
SELECT * FROM login WHERE username = '$username' AND password =
'$password';
when you are logen you have wto id variables user_id(to track user) and
school_id (to link user with some school)

To limit your select to one school try
SELECT * FROM jobs WHERE user_id = '$user_id' AND school_id =
'school_id';
on the other hand if one user can mantain more than one school you can
replace AND to OR and get
SELECT * FROM jobs WHERE user_id = '$user_id' OR school_id =
'school_id';

Good luck
Received on Mon Oct 24 02:09:11 2005