<?php

$host='localhost';
	$user='root';
	$pass='';
	
	//establish database connection
	$conn=mysql_connect($host,$user,$pass) or die('Unable to connect');
	
	//select database for use
    mysql_select_db('acumenchain') or die('Unable to select database!');
	

	    $query2 = "SELECT tblclasslist.studentNo 
					FROM acumenchain.tblclasslist 
					JOIN acumenchain.tblregistration 
					ON tblclasslist.studentNo = tblclasslist.studentNo";
					
		$result = mysql_query($query2) or die('Unable to execute Query' . mysql_error());
        $num = mysql_num_rows($result);
				

	//close connection
    mysql_close($conn);
	
?>

database name : acumenchain
Under my tblclasslist is studentNo (primary key).
Under my tblregistration is studentNo (primary key) and pword
Under my tbllogin is studentNo (primary key) and pword.

Objectives:

  • I want that only students who are registered in the tblclasslist can register on tblregistration.
  • I want that only who are registered can log-in to my site using his/her studentNo and pword.

Thanks:confused:

Try this:

$query2 = "SELECT tblclasslist.studentNo FROM acumenchain.tblclasslist JOIN acumenchain.tblregistration ON tblclasslist.studentNo = tblregistration.studentNo JOIN acumenchain.tbllogin ON tblclasslist.studentNo = tbllogin.studentNo AND tbllogin.studentNo = tblregistration.studentNo";

Does this give the desired result?