Sunday, 25 August 2013

Using JOIN to display data in a table

Using JOIN to display data in a table

Thanks for reading my question
i am trying to make *clients_id* from the table repair_jobs appear as the
name from the table contacts
but i am having no luck i have got 2 sql query's is this wrong?
the 1st
$query = "select * from repair_jobs";
this helps me display the information i need regarding the fields from
repair_jobs and works
this is the 2nd
$query = "SELECT repair_jobs.client_id, contacts.name
FROM repair_jobs
INNER JOIN contacts
ON repair_jobs.client_id=contacts.name";
under that i have this to try to display the name of the client
echo "<td>{$client_id}</td>";
but it is only displaying the number and not the data (clients name) that
i need
am i missing something?



Additional information
The client_id (repair_jobs) is a number and is the same as id (contacts)
but wanting to display the name (contacts)
CLIENTS
Id – name – surname – phone – address
REPAIRS
Id – clients_id (same as id in clients) – unit – date – price

No comments:

Post a Comment