How to make sorting like this: jQuery plugin for sorting HTML tables ?

The fact is that this method does not work, since my data is not ready (not written), but is output from MySQL

 <?php ob_start("ob_gzhandler"); define('INCLUDE_CHECK',true); include($_SERVER['DOCUMENT_ROOT'].'/connect.php'); //$result = mysql_query("SELECT * FROM `applications` ORDER BY `id`") or die(mysql_error()); $result = mysql_query(" SELECT `devices`.*, `selects`.deviceName AS name_device, `divisions`.divisionName AS divisionName FROM `devices` LEFT JOIN `selects` ON `selects`.id = `devices`.name_device LEFT JOIN `divisions` ON `divisions`.id = `devices`.division ORDER BY `devices`.id") or die(mysql_error()); $text = ' <table border="1" style="width:100%;" class="table table-condensed table-bordered table-hover"> <thead> <tr> <!--th style="text-align:center;" width="1%">β„–</th--> <th style="text-align:center;" width="1%;" vertical-align="middle";>НаимСнованиС</th> <th style="text-align:center;" width="8%">Π‘Π΅Ρ‚Π΅Π²ΠΎΠ΅ имя</th> <th style="text-align:center;" width="6%">IP</th> <th style="text-align:center;" width="3%">ΠšΠ°Π±ΠΈΠ½Π΅Ρ‚</th> <th style="text-align:center;" width="3%">ΠžΡ‚Π΄Π΅Π»</th> <th style="text-align:center;" width="18%">БпСцификация</th> <th style="text-align:center;" width="5%">ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΠΈ</th> <th style="text-align:center;" width="9%">Π‘Π΅Ρ€ΠΈΠΉΠ½Ρ‹ΠΉ Π½ΠΎΠΌΠ΅Ρ€</th> <th style="text-align:center;" width="8%">Π˜Π½Π²Π΅Π½Ρ‚Π°Ρ€Π½Ρ‹ΠΉ Π½ΠΎΠΌΠ΅Ρ€</th> <th style="text-align:center;" width="1%"><input type="checkbox" id="selall" value="1" class="checkbox"></th> </tr> </thead>'; while($row = mysql_fetch_assoc($result)) { $text .= ' <tbody> <tr> <!--td>'.$row['id'].'</td--> <td>'.$row['name_device'].'</td> <td>'.$row['netname'].'</td> <td>'.$row['ip'].'</td> <td>'.$row['room'].'</td> <td>'.$row['divisionName'].'</td> <td>'.$row['cp'].", ".$row['motherboard'].", ".$row['ram'].", ".$row['hdd'].", ".$row['vga'].", ".$row['dvd'].", ".$row['corpus'].'</td> <td>'.$row['users'].'</td> <td>'.$row['serial_number'].'</td> <td>'.$row['invent_number'].'</td> <td><input type="checkbox" class="checkbox" value="" name="ip[]"></td> </tr> </tbody>'; } $text .= ''; $text = str_replace('1900-01-01','<span style="color:blue">НС Π²Ρ‹Π΄Π°Π½</span>',$text); echo $text; //Π—Π°ΠΊΡ€Ρ‹Π²Π°Π΅ΠΌ соСдинСниС @mysql_close($result); ?> 
  • Religion does not allow you to make a selection of MySQL, which further wrap in html code as in the example? - Sharp - eyed
  • And I wrote everything that is unclear? How to make a selection from MySQL or wrap it in html code? - Sharp - eyed
  • I already have a sample of all the fields and data from MySQL and turns into HTML - Nicolayka
  • The code in the studio - Sharp - eyed
  • Added code - Nicolayka


1 answer 1

Insert jquery-latest.js and jquery.tablesorter.js , add id for the table, for example, <table border="1" style="width:100%;" class="table table-condensed table-bordered table-hover" id="myTable"> <table border="1" style="width:100%;" class="table table-condensed table-bordered table-hover" id="myTable"> the <tbody> and </tbody> must be removed from the while .
And add to echo "<tbody>$text</tbody>"; and it will work.