mysql php join table problem
Posted: Tue Feb 03, 2009 10:27 am
Hi i have 2 table
customers table
userID
name
appointment table
appointmentID
userID
i need to display out the appointment table where by the appointment.userID is displaying the customers.name instead using php code..i try running
but it doesn't work...anyone can advise me how to get about doing it?
Thanks.
customers table
userID
name
appointment table
appointmentID
userID
i need to display out the appointment table where by the appointment.userID is displaying the customers.name instead using php code..i try running
Code: Select all
$query=("SELECT appointment.userID, customers.userID, customers.name FROM appointment LEFT JOIN customers ON appointment.userID = customers.userID");
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){
echo $row['userID']. " - ". $row['name'];
echo "<br />";
}
Thanks.