I've uploaded the files and the contents doesn't load - as before.
I've added my own connection parameters.
This is what I uploaded.
FYI, our username and database name is XXXXX XXXXX
I doubt the error is the connection parameters.
No I cannot.
Is there a simpler way of doing this?
A basic level but maybe more code?
If not, that's ok.
Here's the error:
var validPostCodes = ['2747','2750','2753','2760','2777'];Unknown column 'ls.postcode' in 'field list'At the bottom of the file:
Thanks do that - our instructor has changed the requirements a few times including the column names in the database.
So i sent you the old one.
It is postcodeID .
in the local_schools table
it is postcodeID
in the valid_postcodes table
it is postcode
Hi you didn't send the new file - cause I don't see any comments as per above.
But I did manage to change mine - this doesn't give any errors now - contents is displayed.
Note - in the png file - 'name' in school_info has also changed to 'Name'
But the select box doesn't come up with anything - once a valid postcode is in.
So now it's a matter of getting the database tables to work together as per the new png file i sent to give me a list of schools.
First, try this one: http://wikisend.com/download/271194/project.php
If that one doesn't work, try this one:
See, you have to join onto the valid_postcodes table. That is an absolute must.
This is actually a ridiculously simple and basic development task. What is making it so difficult is not seeing the actual table schemas. If I could see those, I would have had this code to you in 10 minutes with no issues.
Please remember to check/reload this form more often. I sent these two files over 30 minutes ago. Again, joining with valid_postcodes is absolutely necessary.
ok but in your query
$schoolQuery = $db->prepare("SELECT DISTINCT s.schoolID, s.Name, vp.postcode " . "FROM school_info s " . "JOIN local_schools ls " . "ON s.schoolID = ls.schoolID " . "JOIN valid_postcode vp " . "ON ls.postcodeID = vp.postcodeID " . "ORDER BY s.Name") or die ($db->error);
Didn't work because vp.postcodeID is meant to be vp.postcode
and valid_postcode is meant to be valid_postcodes
So i changed it to this:
$schoolQuery = $db->prepare("SELECT DISTINCT s.schoolID, s.Name, vp.postcode " . "FROM school_info s " . "JOIN local_schools ls " . "ON s.schoolID = ls.schoolID " . "JOIN valid_postcodes vp " . "ON ls.postcodeID = vp.postcode " . "ORDER BY s.Name") or die ($db->error);
And the page loads, but drop box doesn't work.
This is annoying. :)
Great the selection box works!
Except - not sure if there should be that many schools listed for the one postcode.
Here are the database records for each table.
Test it out!
I tried all the postcodes
2777 - i get 6 schools
and I just noticed 3 are primary schools and 3 are high schools.
So the school_type also needs to be taken into consideration.
All the ones marked 'P' in the table.
Because this needs to be all primary schools only.
It's all working now.
Thanks for your help!