I thought we answered this already???
$sql = "
SELECT 'user' AS recordtype, name, addr1, NULL AS s_addr2
FROM user WHERE username = '$user' AND password = '$pwd'
SELECT 'srudent' AS recordtype, s_name, s_addr1, s_addr2
FROM student WHERE username = '$user' AND password = '$pwd'
That doesn't show all the fields, but the idea is the same for all: If a field in STUDENT does not have a similar field in USER, then you need to use NULL AS xxxx
in the first SELECT as a placeholder. If a field in USER does not have a similar field in STUDENT, you can do the same but you can also just omit the AS xxxx
When you look at the query from PHP, *ONLY* the names in the FIRST SELECT will be visible.
So if you do:
$result = mysql_query( $sql );
if ( $row = mysql_fetch_assoc($result ) )
$type = $row["recordtype"]; // will tell you if user or student
$name = $row["name"]; // you can not use $row["s_name"]
$addr1 = $row["addr1"]; // again, can not use $row["s_addr1"]
$addr2 = $row["s_addr2"]; // this is okay because of NULL AS s_addr2 in SQL