Re[3]: [PHP-WIN] Re: php and checkboxes

From: Date: Thu, 08 May 2003 23:41:47 +0000
Subject: Re[3]: [PHP-WIN] Re: php and checkboxes
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-19816@lists.php.net to get a copy of this message
Hello mabat, Friday, May 9, 2003, 1:41:12 AM, you wrote: m> Usually I'm using this scheme: m> <input type=checkbox name="materialid[<? echo m> $row["material_id"];?>]"> m> (Attantion: now we have an array of checkboxes!) m> And after submit m> if (isset($HTTP_POST_VARS["materialid"]) && m> is_array($HTTP_POST_VARS["materialid"])) m> foreach($HTTP_POST_VARS["materialid"] as $key=>$val) m> if ($val=="on") //checked checkbox gives value "on", unchecked - m> "not set" m> mysql_query("DELETE FROM table WHERE material_id='$key'"); >>> I have checkboxs in a form for deletion >>> >>> <input type=checkbox name="materialid<? echo >>> $row["material_id"];?>"> >>> The above code create a checkbox for each row in the table. >>> >>> I would like to delete multiple records using the above. >>> >>> if i check 3 checkboxes for deletion and use >>> >>> matid1=$HTTP_POST_VARS["materialid$matid"]; to find out if the >>> checkbox is checked. It works for the checkboxes that are checked but >>> gives me an MB>> error >>> for the unchecked checkboxes. >>> >>> Erro message: >>> Notice: Undefined index: materialid1020 in >>> e:\..scripts\asset_delete2.php MB>> on >>> line 17 >>> >>> Notice: Undefined index: materialid1030 in >>> e:\..scripts\asset_delete2.php MB>> on >>> line 17 >>> and so on. >>> >>> How can i skip the ones i dont check at all or skip the error message >>> frm showing. I dont care about the ones i dont check in the previous >>> form. >>> >>> Thanks, >>> >>> >>> -- Best regards, mabat mailto:sasha@xxi.co.il

« previous php.windows (#19816) next »