fork download
  1. <?php
  2.  
  3. $author = 1;
  4. $status = "Completed";
  5. $stmt = $con->prepare("SELECT COUNT(i.id_course),
  6. AVG(ra.rating) AS avg_rating
  7. FROM tbl_inscribed i
  8. JOIN tbl_ratings ra
  9. LEFT JOIN tbl_courses c ON i.id_course = c.id_course AND ra.id_course = c.id_course
  10. LEFT JOIN tbl_author a ON c.author = a.id_author
  11. WHERE a.id_author=? AND i.status=?
  12. ");
  13. $stmt->bind_param("is", $author, $status);
  14. $stmt->execute();
  15. $stmt->bind_result($enrolled_instructor, $avg_rating);
  16. $stmt->fetch();
  17. $stmt->close();
Runtime error #stdin #stdout #stderr 0.02s 26348KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Notice:  Undefined variable: con in /home/cXGnhz/prog.php on line 5
PHP Fatal error:  Uncaught Error: Call to a member function prepare() on null in /home/cXGnhz/prog.php:5
Stack trace:
#0 {main}
  thrown in /home/cXGnhz/prog.php on line 5