edit
schon geschaft danke
schon geschaft danke
<form action = "<?php $_SERVER['PHP_SELF']?>" method = "post">
<?php
include "connect.php";
mysql_select_db($datenbank) OR die(mysql_error());
$sql1 = "SELECT cid,name FROM jos_ponygallery_catg;";
$sql2 = "SELECT chid, checked FROM jos_ponygallery_chro;";
$res1 = mysql_query($sql1) OR die(mysql_error());
$res2 = mysql_query($sql2) OR die(mysql_error());
$num1 = mysql_num_rows($res1);
$num2 = mysql_num_rows($res2);
//Überprüfen ob beide Tabellen die gleiche Anzahl an Zeilen haben
//$anzahl = $num1-$num2;
//if ($anzahl <> 0)
//{
//$zeile = $num2;
//for($z=0;$z<$anzahl;$z++)
//{
//$zeile = $zeile+1;
//$insert = " INSERT INTO `jos_ponygallery_chro` (`chid`, `checked`) VALUES ($zeile, 0);";
//mysql_db_query($datenbank, $insert);
//}
//}
//Einsetzen der Variablen
for ($r=0;$r<$num2;$r++)
{
echo $r;
echo $_POST["checkbox".$r.""];
echo "<p></p>";
if ($_POST["checkbox".$r.""] == on)
{
$update = "UPDATE `jos_ponygallery_chro` SET `checked` = '1' WHERE `chid` = $r LIMIT 1;";
mysql_db_query($datenbank, $update);
}
elseif (!$_POST["checkbox".$r.""])
{
$update = "UPDATE `jos_ponygallery_chro` SET `checked` = '0' WHERE `chid` = $r LIMIT 1;";
mysql_db_query($datenbank, $update);
}
}
//Checkboxen auslesen und auflisten
for($x=0;$x<$num2;$x++)
{
$checked = mysql_result($res2, $x, "checked");
echo $checked;
if ($checked == 1)
{
$an = "checked";
}
elseif ($checked == 0)
{
}
$name = mysql_result($res1, $x, "name");
echo "<input type='checkbox' name='checkbox".$x."' $an>";
echo $name;
echo "<p></p>";
}
echo "<input type = 'submit'>";
?>
echo "<input type='checkbox' name='checkbox".$x."' $an>";
if ($_POST["checkbox".$r.""] == on)
Kommentar