Skip to content
Advertisement

Resolve name by ID in from 2 tables in PHP / SQL in Datatable

I am currently working on my first datatable which I managed to get to work and I am quite happy with it, however I am having some difficulties in resolving client names. Here is my current code:

Tablefile.html:

JavaScript

And here my datatable.php file:

JavaScript

The table renders fine and works great, however client_id is obviously just outputting their related ID’s, e.g. 5. How could I convert those client_id’s to the actual client names? I understand that I am currently just fetching from a table called quotes, however the client names (client_name) associated to the client_id’s are in another table called clients and I can’t figure out how to have them combined, I’ve read something about LEFT JOIN but I am not too familiar with SQL commands.

Screenshot of clients table: enter image description here

Some expert help would be greatly appreciated, thank you very much in advance.

EDIT:

I finally got this to work, thanks with the help of MR. @malik-ilman

JavaScript

Advertisement

Answer

Create Query like this :

JavaScript

and display it in array :

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement