Open DataTable

Mysql Join Example

Required files
jquery-2.2.4.js
mysqlJoin_php_datasource.php
style.css
OpenDataTable.js
country_city.sql

Code

see the line in beginning of script in mysqlJoin_php_datasource.php
				
				 	$Cols=array("City.Name","City.District","Country.Name AS country_name","Country.Continent"); // Note please use AS capital only
				 	$Join="LEFT JOIN Country ON City.CountryCode=Country.Code";
		 		
	 		
    
 <html>
   <head>
     <title>Open Data Table</title>
     <script src="https://code.jquery.com/jquery-2.2.4.js"></script>
     <link rel="stylesheet" type="text/css" href="style.css">
     <script src="OpenDataTable.js"></script>
     <script type="text/javascript">
    $(document).ready(function(){
      $(".OpenDataTable").OpenDataTable({  
        url:"mysqlJoin_php_datasource.php",
      });
    });
     </script>
   </head>
   <body>
     <table class="OpenDataTable">
	       <thead>
		       <tr>
			        <th>City</th>
			        <th>District</th>
			        <th>Country</th>
			        <th>Continent</th>
		        </tr>
	       </thead>
       <tbody></tbody>
     </table>
   </body>
 </html>


    

Output

City District Country Continent