php - Inner Join select only two records from mysql -


i have subject , departments table, each subject associated departments table. trying select subjects including departments name. code bellow work perfect show 2 records. appreciated

//select statement $selects=$connection->query("select subjects.id , subjects.name , subjects.related_to , subjects.related_to_sem , departments.dept subjects inner join departments on subjects.related_to = departments.dep_id");  <table class="table table-striped table-bordered bootstrap-datatable datatable"> <thead> <tr> <th>sub id</th> <th>subject name</th> <th>related department</th> <th>related semester</th> <th>actions</th> </tr> </thead>    <tbody> <?php while($result=$select->fetch_assoc()) {  ?> <tr>   <td><?php echo $result['id']; ?></td>   <td class="center"><?php echo $result['name']; ?></td>   <td class="center"><?php echo $result['dept']; ?></td>  <td class="center"><?php echo $result['related_to_sem']; ?></td>  <td class="center">  <a class="btn btn-info" href="#"> <i class="icon-edit icon-white"></i>   edit                                             </a> <a class="btn btn-danger" href="#"> <i class="icon-trash icon-white"></i>  delete </a> </td> </tr> <?php } ?> </tbody> </table> 

select   subjects.id,subjects.name, subjects.related_to, subjects.related_to_sem, departments.dept     subjects  left outer join departments on subjects.id=departments.dep_id 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -