Aftab Ali Aftab Ali - 1 year ago 77
MySQL Question

How to fetch data from two tables info using php

I want to get data from two tables. I have patient first name and last name in one table and appointment time in other table. I am using following way but it gives an error:

FROM PatientMaster
JOIN ProviderAppointmentListings
ON PatientMaster.PatientID = ProviderAppointmentListings.PatientID

$result = mysql_query($query) OR die(mysql_error());
$rows = array();
while($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
echo json_encode($rows);

it prints here query empty

Answer Source



$query="SELECT PatientMaster.FirstName,PatientMaster.LastName,ProviderAppointmentListings.AppointmentTime 
FROM PatientMaster JOIN ProviderAppointMentListings ON PatientMaster.PatientID = ProviderAppointmentListings.PatientId";

$result = mysql_query($query) or die(mysql_error());

If a MySQL error appears, then there must be something wrong with your query.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download