Support » How-To and Troubleshooting » html table using 3 sql tables. create matrix?

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

    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)
  • 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.
Skip to toolbar