I have a task, I need to make it possible to sort the table by last name or first name. Install the plugin from here http://tablesorter.com/docs/ Connected as indicated in the documentation. But does not work. My table is generated automatically. What could be the problem? Where to look?

<table id="myTable" class="tablesorter" align="center" border="1"> <thead> <tr> <td>Фамилия</td> <th>Имя</th> <th>Возраст</th> <th>Телефон</th> <th>Умеет водить</th> <th>Статус</th> <th>Редактировать</th> </tr> </thead> 

Next comes a piece of code for pagination, and then the table output.

 while($row = mysql_fetch_assoc($result)):?> <tbody> <tr> <td> <?echo $row['sname'];?> </td> <td> <?echo $row['name'];?> </td> <td> <?echo calculate_age($row['dateb']);;?> </td> <td> <?echo $row['mob'];?> </td> <td> <?echo $row['buses'];?> </td> <td> <input id='input<?=$row['id']?>' name='active' type='checkbox' value ='<?=$row["active"]?>' onchange="on_change(<?=$row['id']?>)" <?php if($row['active'] == '1') {echo 'checked="checked"';} else { echo "";} ?> /> </td> <td> <a href = "index.php"> Изменить </a> </td> </tr> </tbody> <? endwhile;?> </table> 
  • Without code, we can not help you. Share the code - Urmuz Tagizade
  • I do not even know what piece to put. @UrmuzTagizade here put the code into the question - Anykey
  • Scripts correctly connected? - Urmuz Tagizade
  • @UrmuzTagizade as stated in the documentation <script type = "text / javascript" src = "/ path / to / jquery-latest.js"> </ script> <script type = "text / javascript" src = "/ path / to /jquery.tablesorter.js "> </ script> paths of course your own - Anykey

1 answer 1

Understood himself. The point is that the tbody tag is looped. If you put it before the cycle, then everything is as it should