echo "<form method='POST' action=''><br>";
$query = mysql_query("set names 'utf8'");
$query = mysql_query("
SELECT * FROM pages WHERE user_id = '$_SESSION[user_id]'
") or die(mysql_error());
while($pagek = mysql_fetch_array($query)) {
$name = $pagek['page_name'];
$pageid = $pagek['page_id'];
echo '<input type="checkbox" name="page_ids[]" value="'.$pageid.'">'
.$name
."<br>";
}
echo "<br>
<input type='submit'
value='Adatok frissítése'
name ='adat'
class='button small radius center black'
>";
echo "</form>";
foreach($_POST['page_ids'] as $page){
if ($page){
mysql_query("
UPDATE pages
SET page_value = '0'
WHERE user_id = '$_SESSION[user_id]'
");
mysql_query("
UPDATE pages
SET page_value = '1'
WHERE user_id = '$_SESSION[user_id]'
AND page_id = '$page'
");
}
}
我喜欢,然后如果选中了哪个复选框,这个mysql更新1,并且超过0。
这段代码不好,这里只有一个站点更新就搞定了,其余的都是零,而且你可以随时选择站点