Jump to content

Recommended Posts

Posted (edited)

Evening,

 

Wondering if someone can point me in the right direction. I have 3 tables that have data and another table that has what I think is a link to that data (i've attached the structure to help) however I can't figure out how to this data to display in a table.

 

Hope this makes sense,

 

Stuart

DBStructure.docx

Edited by Stuart-Hannah
Add attachments
Posted
Looks like a basic star schema, you've got some basic mistakes with it. For starts studentar has wrong data type for columns. Also not a fan of raw php code, you should be using a framework like Laravel.
Posted

Have a look on https://laracasts.com - great for beginners, other one is Pluralsight. Its a bit hard to compress 5 years worth of training down to a forum post ;)

 

Personally I just nag web developer to do it for me or at least get me started. Takes them a few moments, saves me days

  • 2 weeks later...
Posted (edited)

Hi there,

 

At it's simplest, to join those up all you need is some INNER JOIN's. I would start by altering the data types in Studenar so that CandidateID, AdjustmentID, and SubjectID match their respective PKs, so all 3 should have a data type of INT(11)

 

From there, this will just join the 4 tables up and get all data points

 

SELECT
   sar.StudentADID,
   c.*,
   s.*,
   a.*
FROM Studentar sar
INNER JOIN Candidates c
   ON c.CandidateID = sar.CandidateID
INNER JOIN Subjects s
   ON s.SubjectID = sar.SubjectID
INNER JOIN Adjustments a
   ON a.AdjustmentID = sar.AdjustmentID

 

From there you can limit, maybe add WHERE a.AdjustmentActive = 'y' ( or whatever that contians )

 

Let me know if there's anything else I can help with, I've spent a lot of time on StackOverflow helping people with MySQL queries

 

From here, you'll need to fire that query off using PHP, and then loop over the rows rendering your HTML. Afraid I tend to deal more with Coldfusion/NodeJS nowadays though so can't really help too much there.

Edited by SimonHooker
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...