Php Checkbox - check machen und deaktivieren

ich versuche, ein problem zu lösen.

Php Checkbox - check machen und deaktivieren

und das ist mein code.

<?php

require 'connectDB.php';
print<<<_A_
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
_A_;
$mysql = new mysql();
$mysql->connect();

$dbResult = mysql_query("select * from profiles");






echo "<form action='#' method='post'>";

$dbResult = mysql_query("select * from profiles");


while ($info = mysql_fetch_array($dbResult)) {

    if ($info['isPremium'] == 0)
        echo "<input type=checkbox name='check2[]' id='check2' value=".$info['id'].">";
    else
        echo "<input type=checkbox name='check1[]' id='check1' value=".$info['id']." checked>";

    echo $info['profileName'] . "<br />";
}

echo "<p><input type='submit' name='btnPremium' /></p>";
echo "</form>";

Wenn Benutzer klicken Sie auf ein Markierungsfeld, ich sende db eine Abfrage, um es 1.Wenn ein Nutzer jedoch deaktivieren Sie ein Kontrollkästchen, nehme ich diese Fehlermeldung: Undefined index: check2 in C:\xampp\htdocs\googleAnalytics\GAPI\choosePremium.php auf der Linie 43 ich versuche immer, deaktiviert in arrPremium2 :S

if (isset($_POST['btnPremium'])) {

    $arrPremium = $_POST['check1'];
    foreach($arrPremium as $result)
    {
        mysql_query("UPDATE profiles set isPremium=1 where id=".$result."");
    }

    $arrPremium2 = $_POST['check2'];
    print_r($arrPremium2);
}
?>
InformationsquelleAutor Mert METİN | 2012-02-22
Schreibe einen Kommentar