Jump to content

SQL Help needed


genzedu777

Recommended Posts

I went ahead and looked at the document you provided.  Your structure is correct.  subject_level is a classic Many to Many relationship resolver table, resolving the many to many relationship between subject and level.

 

What I would recommend for your queries supporting the forms you're generating, is that you join the tables together using a standard inner join.  You can then order result by level.  As you loop through the result set, you simply set an outer variable on level.  Anytime the level in the result set changes, you would emit a new section with the level heading and a new set of checkboxes. 

 

I would go so far as to say that you should take the same approach in your prior code, where you are instead doing 2 queries.  That is not necessary, as joining the tables together will get you everything you need in one.  If you need the results for only one level, you can always include that in the WHERE clause for the query.

 

If you have any specific questions in regards to your coding, feel free to post them in a followup.

 

 

Link to comment
https://forums.phpfreaks.com/topic/218002-sql-help-needed/#findComment-1133584
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.