Hi I am trying to teach myself object and function on php, I am at a point where i can create my own defined functions but i have a little problem with mysql on how to check if something exist on the other table or invoke my function to work properly
let me explain it here I have a table1 Student_Outstanding(Server1) which only holds student number of people who have outstanding fees
and I have a second table2 which Student_Information(Server 2) which holds all the student information registered in that institution,so since this table holds a lot of information like thousands of records
How do i fetch the student information(table 2) of only student numbers which exist in table 1
1st function fetches student number
function fetchStudentNumber($num)
{
require(CONNECTIONS.'conn.php');
$sql = "SELECT * FROM Students WHERE Student_Number='".$num."' ";
$result=mysql_query($sql);
$lines = array();
while($rows=mysql_fetch_array($result)){
$lines[] = $rows;
}
return $lines;
}
second function fetches student information(outstanding) and add it to a new table before it can email it but my problem is here how do i check if the student in table one exist in table2 and only select that information help with mysql
function fetchStudentInfo(){
require (CONNECTIONS.'connection.php');
$resource1 = "SELECT Student_Name, Reg_Date, StudentNumber , Course, Tel, DOB_Date FROM Student_Out";
$result1=mysql_query($resource1);
while ($rows = mysql_fetch_array($result1)) {
$stuname = $rows['Student_Name'];
$regdate = $rows[' Reg_Date'];
$stunum = $rows['StudentNumber'];
$cos= $rows['Course'];
$tel= $rows['Tel'];
$dob= $rows['DOB_Date'];
require (CONNECTIONS.'db_conn.php');
$way = true;
if ($stunum != "") {
if ($way) {
$resource2 = "INSERT IGNORE INTO Student_outstandingfees
(Student_Name, Reg_Date, StudentNumber , Course, Tel, DOB_Date) VALUES
('".$stunum."', '".$regdate."', '".$stunum."', '".$cos."', '".$tel."', '".$dob."')";
$way = false;
}
else {
$resource2 = $resource2.",
('".$stunum."', '".$regdate."', '".$stunum."', '".$cos."', '".$tel."', '".$dob."')";
}
}
$result2=mysql_query($resource2) or die("Cannot insert into student outstanding");
}
}