Помогите решить проблему!
Скрипт не отправляет массив чекбоксов, отправляет только один id почему?, когда выбираю одну позицию в таблице все ок а когда несколько то только один id.
Сам код:
<?php
ini_set("display_errors",1);
error_reporting(E_ALL);
include ('inc/conf.php'); // Connect db
include ('inc/func.php'); // function
$site = $_SERVER['SERVER_NAME'];
require_once('api-class/pagination.php');
$query = mysql_query('SELECT COUNT(*) AS `count` FROM `domain`');
$result = mysql_fetch_assoc($query);
$pagination = new Pagination($result['count'], 20);
$i=0;
$query = mysql_query('SELECT * FROM `domain` LIMIT ' . $pagination->skip() .', '. $pagination->take());
echo '<table class="table table-bordered">';
echo '<thead>
<tr>
<th>act</th>
<th>Domain</th>
<th>Source Category</th>
<th>Backlinks</th>
<th>Competitor Relevance</th>
<th>Organic Traffic</th>
<th>AlexaRank <a href="index.php?sort=desc"><b>∧</b></a> <a href="index.php?sort=asc"><b>∨</b></a> <a href="index.php?sort=zero"><b>0</b></a></th>
<th>Category</th>
</tr>
</thead>';
echo '<div class="poisk"><form action="search-domain.php" method="get" class="navbar-search pull-right">
<input type="text" name="q" class="search-query" placeholder="Search Domain">
</form></div>';
while($result = mysql_fetch_assoc($query)){
$i++;
echo '<tbody>
<tr>
<td style="width:1%; height:10px;"><div class="checkbox"><form id="data">
<label>
<input type="checkbox" name="checkboxid[]" value="'.$result['id'].'">
</label></form>
</div></td>
<td style="width:10%; height:10px;"><a href="http://'.$result['domain_name'].'" target="_blank">'.$result['domain_name'].'</a></td>
<td style="width:10%; height:10px;">'.$result['source_category'].'</td>
<td style="width:5%; height:10px;">'.$result['backlinks'].'</td>
<td style="width:5%; height:10px;">'.$result['competitor_relevance'].'</td>
<td style="width:5%; height:10px;">'.$result['organic_traffic'].'</td>
<td style="width:5%; height:10px;">'.$result['alexa_rank'].'</td>
<td style="width:8%; height:10px;">
<form>
<select name="select-cat">
<option selected value="">Select Category</option>
<option value="Download Portals">Download Portals</option>
<option value="Tech Blog">Tech Blog</option>
<option value="Forums">Forums</option>
<option value="Drivers">Drivers</option>
<option value="Files, Libraries, Errors">Files, Libraries, Errors</option>
<option value="Software Developers">Software Developers</option>
<option value="Affiliate Network">Affiliate Network</option>
<option value="Speed, IP checkers">Speed, IP checkers</option>
<option value="Other">Other</option>
</select>
<button formaction="select-processing.php?a=add&id='.$result['id'].'" formmethod="post" class="btn_prog">Processing</button>
</form>
</td>
</tr>
</tbody>';
}
echo '</table>';
echo '<button formaction="checkbox-rem.php" formmethod="post" form="data" class="btn btn-primary">Remove</button>';
$count_zapis = $pagination->skip();
echo '<div class="count_zapis">Showing '.$i.' to ';
if($count_zapis == '0') {
echo $i;
}else{
echo $pagination->skip();
}
echo ' of '.mysql_num_rows(mysql_query("SELECT * FROM `domain`")).' entries</div>';
echo $pagination->get();
?>
Файл который принимает:
<?php
include ('inc/conf.php'); // Connect db
$arr = $_POST['checkboxid'];
if(empty($arr))
{
echo("You do not choose.");
$referer=getenv("HTTP_REFERER");
echo "</br> <a href=\"$referer\">Back</a>";
}
else
{
$N = count($arr);
$comma_id = implode(",", $arr);
$query="SELECT * FROM `domain` WHERE id IN ($comma_id)";
if ($res=mysql_query($query)){
while($row=mysql_fetch_assoc($res)){
$dom = $row['domain_name'];
mysql_query("INSERT INTO `removed` (`domain_name`) VALUES ('" . $dom . "')");
}
}
for ($i=0; $i < $N; $i++)
{
mysql_query("DELETE FROM domain WHERE id=".$arr[$i]."");
}
if(!mysql_query($query1))
{
echo 'Error!</br> '.mysql_errno().' : '.mysql_error().' . <br>';
$referer=getenv("HTTP_REFERER");
echo "</br> <a href=\"$referer\">Back</a>";
die();
}
else
{
echo 'Success! Removed';
$referer=getenv("HTTP_REFERER");
header("Location: $referer"); /* Redirect browser */
die();
}
}
?>