Advertisement
mauricioribeiro

PHP solution

Jul 20th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. <?php
  2.     $db = new mysqli('localhost','root','','test');
  3.     $result = $db->query("SELECT students.*,teachers.name FROM students,teachers WHERE students.id='$id' AND students.class = teachers.class");
  4.  
  5.     if($result->num_rows){
  6.         while ($row = $result->fetch_assoc()) {
  7.             echo 'Name: '.$row['name'];
  8.                        echo 'Class: '.$row['class'];
  9.         }
  10.     }
  11.  
  12.     mysqli_close($db);
  13. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement