Моя таблица подгружается из БД, задача таблицы заключается в то, что надо выбрать нужные строки с помощью чекбоксов и отправить в БД, обновляя данные.
Я использовала популярный плагин JQuery tablesorter для сортировки таблицы. Вот ссылка: tablesorter.com/docs/#Download, т.е. при нажатии на заголовке, таблица сортируется.
Так вот, проблема в том, что после нажатия на заголовок, я начинаю ставить галки и нажимаю submit и он не обновляет данные.
Вопрос, почему, если не нажимать на заголовок для сортировки, я спокойно могу обновляет данные, а если нажать на заголовок данные данные уже не изменить? В чем конфликт?
Вот код осталось подключить плагин к нему:
<html>
<head>
<title>tablesorter</title>
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript" src="jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="sort.js"></script>
<link href="otzyvy.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include (sql_connect.php');
header("Content-Type: text/html; charset=utf-8");
if(isset($_POST['act1'])){
foreach ($_POST['act1'] as $comment_id=>$moderation) {
mysql_query("UPDATE table_com SET moder='1' WHERE id=".$comment_id);
}
}
if(isset($_POST['act0'])){
foreach ($_POST['act0'] as $comment_id=>$moderation) {
mysql_query("UPDATE table_com SET moder='0' WHERE id=".$comment_id);
}
}
if(isset($_POST['act3'])){
foreach ($_POST['act3'] as $comment_id=>$moderation) {
mysql_query("DELETE FROM table_com WHERE id=".$comment_id);
}
}
$table = mysql_query("SELECT com, timing, moder , id FROM table_com");
?>
<table id="large" cellspacing="0" class="tablesorter">
<thead>
<tr>
<th class="head">Отзывы</th>
<th class="head">Время</th>
<th class="head">Модерация</th>
<th class="head">Выборка</th>
</tr>
</thead>
<tbody>
<?php
if(!$table) die("Error_select: " . mysql_error());
$rows = mysql_num_rows($table);
for($j=0; $j<$rows; $j++){
$row = mysql_fetch_row($table);
?>
<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>
<?php }?></tbody></table><input class="button" name="button" type="submit" value="Отправить" /></form>
</body>
</html>