Title: html table using 3 sql tables. create matrix?
Last modified: August 20, 2016

---

# html table using 3 sql tables. create matrix?

 *  [j3ddesign](https://wordpress.org/support/users/j3ddesign/)
 * (@j3ddesign)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/html-table-using-3-sql-tables-create-matrix/)
 * m currently creating a site for work and have gotten the majority of the functionality
   there, however i’ve run into a problem when im trying to use data from 3 different
   tables in sql.
 * I have the queries set up and functional, im just not sure on the php code im
   supposed to be using to get this right.
 * Tables set up is as follows: three tables, one “allcourses”, one “wp_users”, 
   and one “completed courses”.
 * I am creating an HTML table using this data. I currently have it displaying rows
   using coursenames from allcourses and columns based on display_name from wp_users.
   the link is “completed” from completed courses.
 * completed courses is a table to link all courses and wp_users, and allow me to
   see who has and hasn’t completed a certain training course in a matrix.
 * here is the code: [http://pastebin.com/fZpgpM3m](http://pastebin.com/fZpgpM3m)
 * what i want to happen is where there is a value for “completed”, the block shows
   green in the right section for the courseid and userid. where there is not a 
   value, a default shows.
 * as it stands right now, the code i have is giving me every single block as green.(
   I would assume as it is only finding the one row currently in the table and looping
   that). I would like it to recognize where there is and is not a value. assuming
   thats possible.

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/html-table-using-3-sql-tables-create-matrix/#post-3107802)
 * I can’t be sure, but I think the problem might be in the test for $result->completed.
   Try changing this:
 *     ```
       if ($result->completed){
          while (($result->completed = 'y'))
             $tbl->addCell($result->completed, 'greenbg');
       } else {
          $tbl->addCell($result->completed, 'redbg');
       ```
   
 * to this:
 *     ```
       if ($result->completed == 'y'){
          $tbl->addCell($result->completed, 'greenbg');
       } else {
          $tbl->addCell($result->completed, 'redbg');
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘html table using 3 sql tables. create matrix?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/html-table-using-3-sql-tables-create-matrix/#post-3107802)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
