سؤال

I am in need of some help, I have a table where it shows the people that have signed into a patient program.

Here is how it looks:

Right now if you look in the Location column, it says 8 instead of the last option in the dropdown being Manalapan.

Here is how the database table looks for offices location:

I would like to grab the office_name data from the database while retrieving the patient information in the table,from the table patients:

It is stored in the database as pat_loc and this one is 8.

In the end, I want it to say the name of the office, not the number it is stored at, first getting it from the patient table then going to the office table for the name.

Is there such a thing that can be done?

If needed, I will show my current code to see where it needs to be added.

هل كانت مفيدة؟

المحلول

You could try doing an inner join so you can grab all the data you need from both tables

SELECT * FROM patients INNER JOIN offices ON office_id = pat_loc

And then accessing it through your row array like $row['office_name]

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top