Check your query:
$query=" SELECT `fname`,`lname`,`appointment_date`,`appointment_time`,`message`,`remark`,`status` FROM `appointments` INNER JOIN `patients` ON appointments.patientid= patients.id INNER JOIN doctors ON appointments.doctor_id=doctors.id";
At a guess (and without your DB that's all it can be) you need to explicitly reference the table that the filed is coming from:
MySQL Joins[
^]