I am new to PHP as well as to this forum. Thanks in advance for you support.
My problem is to retrieve data from multi tables. I have tables like Zones, Division, Schools and Teachers. In a single Zone there can be many divisions and in a single division there can be many schools. I need to make a query to find out all the teachers in a particular zone.
I made the query like below,
$query = $this->dbh->prepare("SELEC T * FROM teachers,school _locations where teachers.nic=(S ELECT nic FROM teacher_appoint ments where teacher_appoint ments.census_id =(SELECT census_id FROM school_location s where school_location s.division_id=( SELECT division_id FROM divisions WHERE divisions.divis ion_name='$_POS T[division_name]')))");
this works fine when there is only one zone, one division and one school. I used foreach loop to view the data on this case and the problem is when there are many schools for a given division.
My foreach loop looks like below...
Can anyone please let me know how to show the data from multiple tables?
My problem is to retrieve data from multi tables. I have tables like Zones, Division, Schools and Teachers. In a single Zone there can be many divisions and in a single division there can be many schools. I need to make a query to find out all the teachers in a particular zone.
I made the query like below,
$query = $this->dbh->prepare("SELEC T * FROM teachers,school _locations where teachers.nic=(S ELECT nic FROM teacher_appoint ments where teacher_appoint ments.census_id =(SELECT census_id FROM school_location s where school_location s.division_id=( SELECT division_id FROM divisions WHERE divisions.divis ion_name='$_POS T[division_name]')))");
this works fine when there is only one zone, one division and one school. I used foreach loop to view the data on this case and the problem is when there are many schools for a given division.
My foreach loop looks like below...
Code:
foreach ($teachers AS $row) { echo "<tr>"; $i = $i + 1; echo "<td>$i.</td> <td>" .$row[division_id]."</td> <td>" .$row[nic]."</td> <td>" .$row[name_initials]."</td> <td>" .$row[name_full]."</td> <td>". $row[date_of_birth]."</td> <td>". $row[sex]."</td> <td>". $row[address_permanent]."</td> <td>". $row[zone_id]."</td>"; }
Can anyone please let me know how to show the data from multiple tables?
Comment