yes, as I said in an earlier post, I used to have 30 if ($key) statements, one for each checkbox, in the order I wanted to write them in. This is not optimal because: (a) it is a ton of code, (b) the checkboxes could in the future increase in number, change order, etc. and then I would have to recode this section to match. The solution I used to solve this was to remove the table, put all the checkboxes into <div> elements, float them into columns and now they appear in the same order as before when they were in a table, but they write to the $_POST variable in the order that I want. - Ben On 6/8/06, João Cândido de Souza Neto <joao@xxxxxxxxxxxxxxxxxxxxx> wrote:
I don´t test, but it can works fine: foreach ($_POST as $key => $data) { switch ($key) { case "aaa" $query.="$key, "; break; case "bbb" $query.="$key, "; break; case "ccc" $query.="$key, "; break; } } In switch you can order by ordening the cases. Hope help. ----- Original Message ----- From: "Ben Liu" <blzabub8@xxxxxxxxx> To: "João Cândido de Souza Neto" <joao@xxxxxxxxxxxxxxxxxxxxx> Cc: <php-general@xxxxxxxxxxxxx> Sent: Thursday, June 08, 2006 1:14 PM Subject: Re: Re: order of elements in $_POST super global Hello João, You are right that the $_POST variable does not receive anything for unchecked boxes. I didn't realize that. But I still need the foreach loop for other reasons: So it looks like this: foreach ($_POST as $key => $data) { $query.="$key, "; } Instead of this: foreach ($_POST as $key => $data) { if ($data) $query.="$key, "; } Thanks, Ben On 6/8/06, João Cândido de Souza Neto <joao@xxxxxxxxxxxxxxxxxxxxx> wrote: > Since i remember, when a for POST is sent and a checkbox is not checked, > php > not receive this $_POST variable. > > That is, i think you don´t need to use a foreach to know if checkbox was > checked or not. > > Am i wrong?
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php