Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   вопрос по tablesorter(сорировка таблицы) (https://javascript.ru/forum/jquery/39210-vopros-po-tablesorter-sorirovka-tablicy.html)

Nailya 20.06.2013 15:20

вопрос по tablesorter(сорировка таблицы)
 
Всем привет!

Использовала плагин tablesorter(ниже ссылка) для сортировки таблицы.
если прописать несколько <tr> и <td>, то сортировка работает исправно,но у меня <tr><td> в цикле и он не работает.

Вопрос, почему такой вариант не работает?

http://www.jstoolbox.com/2008/05/14/...c-dlya-jquery/


$(document).ready(function() 
    { 
        $("#large").tablesorter(); 
    } 
);

Вот код:
<table id="large" cellspacing="0" class="tablesorter">

<thead>
	 <tr>
         <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Отзывы</th>
		 <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Время</th>
		 <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Модерация</th>
		 <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Выборка</th>
     </tr>
</thead>
<?php

	if(!$table) die("Error_select: " . mysql_error());
	$rows = mysql_num_rows($table);
	
	for($j=0; $j<$rows; $j++){
		$row = mysql_fetch_row($table);
?>

<tbody>
		<tr>
			<td> <?php echo $row[0] ?></td>
			<td> <?php echo $row[1] ?></td>
			<td> <?php echo $row[2] ?></td>
			<td><form action="adminka.php" method="post">
                Добавить<input type="checkbox" id="select_1" name="act1[<?php echo $row[3]?>]">
                На модерации<input type="checkbox" id="select_0" name="act0[<?php echo $row[3]?>]">
                Удалить<input type="checkbox" id="delete" name="act3[<?php echo $row[3]?>]"></td>
		</tr>
		
		  
</tbody><?php }?>
</table>

skrudjmakdak 20.06.2013 15:52

можете прислать с генерированную html страницу
если цикл большой, сократите его искусственно, чтобы с генерированная страница не была большой

skrudjmakdak 20.06.2013 15:53

и если можно ссылку на tablesorter для скачивания, чтобы я не рыскал эту либу по нету

Nailya 20.06.2013 16:02

Сгенерированная страница небольшая(11 строк)

вот плагин
tablesorter.com/docs/#Download

подключила эти два файла:
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript" src="jquery-latest.js"></script>

skrudjmakdak 20.06.2013 16:07

нууу и)) скидывайте вашу html я не телепат)

Nailya 20.06.2013 16:17

sort1.php

<?php 
include ('connect_data.php');
header("Content-Type: text/html; charset=utf-8");
?>
<html>
<head>
<title>tablesorter</title>
	<script type="text/javascript" src="jquery-latest.js"></script>
	<script type="text/javascript" src="sort.js"></script>
	<script type="text/javascript" src="jquery.tablesorter.js"></script>
	<link href="otzyvy.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php 
$table = mysql_query("SELECT com ,
		 time , moderation , id FROM table_com");
?>
<table id="large" cellspacing="0" class="tablesorter">

<thead>
	 <tr>
         <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Отзывы</th>
		 <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Время</th>
		 <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Модерация</th>
		 <th rowspan="2" class="head" class="headerSortUp" class="headerSortDown">Выборка</th>
     </tr>
</thead>
<?php

	if(!$table) die("Error_select: " . mysql_error());
	$rows = mysql_num_rows($table);
	
	for($j=0; $j<$rows; $j++){
		$row = mysql_fetch_row($table);
?>

<tbody>
		<tr>
			<td> <?php echo $row[0] ?></td>
			<td> <?php echo $row[1] ?></td>
			<td> <?php echo $row[2] ?></td>
			<td><form action="sort1.php" method="post">
                Добавить<input type="checkbox" id="select_1" name="act1[<?php echo $row[3]?>]">
                На модерации<input type="checkbox" id="select_0" name="act0[<?php echo $row[3]?>]">
                Удалить<input type="checkbox" id="delete" name="act3[<?php echo $row[3]?>]"></td>
		</tr>
		
		  
</tbody><?php }?>
</table>
	
	</body>
</html>

skrudjmakdak 20.06.2013 16:32

Nailya, вы знайте в чем разница между php и html. вы мне сейчас php скинули, а мне надо html. php кода в чистом html быть не должно

skrudjmakdak 20.06.2013 16:34

в браузере нажмите ctrl + u. откроется (должно) новое окно
скопируйте и вставьте сюда

Nailya 20.06.2013 16:42

я только не понимаю, что вы хотите с чистым html сделать, если вы хотите проверить работает она или нет, то да, работатет

<html>
<head>
<title>tablesorter</title>
</head>
<body>
<table id="large" cellspacing="0" class="tablesorter">
	
	<thead>
		 <tr>
              
              <th rowspan="2">Three</th>
				<th rowspan="2">Three</th>
				<th rowspan="2">Three</th>
              <th rowspan="2">Three</th>
				<th rowspan="2">Three</th>
           </tr>
		<tr>
			<th>Name</th>
			<th>Major</th>
			
		</tr>
	</thead>
	<tfoot>
		<tr>
			<th>Name</th>

			<th>Major</th>
			<th>Sex</th>
			<th>English</th>
			<th>Japanese</th>
			<th>Calculus</th>
			<th>Geometry</th>

		</tr>
	</tfoot>
	<tbody>
		<tr>
			<td>Student01</td>
			<td>Languages</td>
			<td>male</td>

			<td>80</td>
			<td>70</td>
			<td>75</td>
			<td>80</td>
		</tr>
		<tr>
			<td>Student02</td>

			<td>Mathematics</td>
			<td>male</td>
			<td>90</td>
			<td>88</td>
			<td>100</td>
			<td>90</td>

		</tr>
		<tr>
			<td>Student03</td>
			<td>Languages</td>
			<td>female</td>
			<td>85</td>
			<td>95</td>

			<td>80</td>
			<td>85</td>
		</tr>
		
	</tbody>
</table>
	
	</body>
</html>

skrudjmakdak 20.06.2013 16:49

мы видимо друг друга не понимаем. пришлите скан. и опешите что у вас не идет

и мне что то с трудом верится, что это с генерированная html по вашему php, т.к. ответ вы пишите совсем другой.. а с генерироваться должно совсем другое..


Часовой пояс GMT +3, время: 19:20.