开发者

Checkbox Post Array Empty

Can someone please help me figure out what is wrong with this arr开发者_JAVA百科ay. I've tried everything but it is always coming up empty in my post.

Greatly appreciated, Paul.

FORM

while ($rowcat2 = mysql_fetch_array($resultcat2)) { 
        $accSubcatID = $rowcat2["id"];
        $accvalue = $rowcat2["value"];

    <span><?=$accvalue?>:</span><input type="checkbox" name="accSubcat[]" id="accSubcat[]" style="margin-right:10px;" value="<?=$accSubcatID?>" />

}

POST DATA

  if(!empty($_POST['accSubcat'])){

    foreach($_POST['accSubcat'] as $key) {

        $accsubcatID = $key;

        if ($accsubcatID) {

    $sql3= "INSERT INTO yt_acc_data (busID,subcatID)
    VALUES ('$busID','$accsubcatID')";
    //Execute SQL statement

        if(!($mysql_rs3 = mysql_query($sql3)))
        die("Error in executing query3");

        }
    }

}


@tomalak suggest a good point

now first i say u must check

echo "<pre>";
print_r($)POST);

if post array coming properly then , i just optimize your mysql/php way, have a look

btw what is $mysql_rs3 with that u r comparing the mysql statement in if condition??

if(!empty($_POST['accSubcat'])){
    foreach($_POST['accSubcat'] as $key=>$value) 
    {
     if (!empty($value)) {
        // i think datatype of *busID* and *subcatID* is integer
        $sql3= "INSERT INTO yt_acc_data (busID,subcatID) VALUES ($busID,$accsubcatID)";
        //Execute SQL statement         
        if(!(mysql_query($sql3)))
            die("Error in executing query3");
       }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜