Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

allcourses

By: a guest on Oct 10th, 2012  |  syntax: PHP  |  size: 1.05 KB  |  views: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php get_header('allcourses');
  2.  
  3. global $wpdb;
  4.  
  5. $results = $wpdb->get_results(
  6.                 "
  7.                 SELECT * FROM
  8.                 ( Select * FROM allcourses as ac JOIN completedcourses as cc ON ac.id=cc.courseid WHERE 1 ) as T12
  9.                 JOIN wp_users as u ON T12.courseid=u.ID WHERE 1
  10.                 "
  11. );
  12.  
  13. $tbl = new HTML_TABLE(null, 'display', 1, 0, 4);
  14. $tbl->addRow();
  15. $tbl->addCell('Course Name', 'first', 'header');
  16. $tbl->addCell('Course Value', 'first', 'header');
  17.  
  18. //ADD NAME COLUMNS
  19. foreach ($results as $result)
  20.         {
  21.                 $tbl->addCell($result->display_name, 'first', 'header');
  22.         }
  23.  
  24. //ADD COURSE ROWS
  25. $courses = $wpdb->get_results(
  26.                 "
  27.                 SELECT * FROM allcourses
  28.                
  29.                 ", OBJECT_K
  30. );
  31. foreach ( $courses as $course )
  32. {
  33.         $tbl->addRow();
  34.                 $tbl->addCell($course->coursename);
  35.                 $tbl->addCell($course->coursevalue);
  36.                 //ADD COMPLETED MATRIX
  37.                 if ($result->completed){
  38.                         while (($result->completed = 'y'))
  39.                         $tbl->addCell($result->completed, 'greenbg');
  40.                 } else {
  41.                 $tbl->addCell($result->completed, 'redbg');
  42.         }
  43.                
  44. }
  45. //DISPLAY TABLE
  46. echo $tbl->display();
  47.  
  48. get_footer(); ?>