You need to name the elements a little differently. You're on the right
track with making them an array, but if I check the third box, that'll make
$check[0] = 1, and if I put in a name in the first box, that'll make
$name[0] = 'John'... so you have no way of relating the name from "entry
one" to the checkbox in "entry one".

So, the easy fix for this is to supply the key yourself.

<p>Entry One
<input type=text name=name[1]>
<input type=text name=tel[1]>
<input type=checkbox name=check[1] value=1>

<p>Entry Two
<input type=text name=name[1]>
<input type=text name=tel[1]>
<input type=checkbox name=check[1] value=1>

Now, when that is submitted, only the checked values will be passed in
$check.. so you can do this (assuming POST):

foreach($_POST['check'] as $key => $value)
{
  if(empty($_POST['name'][$key]))
  { echo "you didn't supply a name for entry $key"; }
  if(empty($_POST['tel'][$key]))
  { echo "you didn't supply a telephone number for entry $key"; }

  //process $_POST['name'][$key] and $_POST['tel'][$key]
}

Hope that helps. Sorry for the top post, but OE sucks. :)

---John Holmes...

----- Original Message ----- 
From: "Aris Santillan" <[EMAIL PROTECTED]>
To: "Php (E-mail)" <[EMAIL PROTECTED]>
Sent: Tuesday, August 26, 2003 11:21 PM
Subject: [PHP] dealing with arrays


hi


I Have
<p>Entry One
<input type=text name=name[]>
<input type=text name=tel[]>
<input type=checkbox name=check[] value=1>

<p>Entry Two
<input type=text name=name[]>
<input type=text name=tel[]>
<input type=checkbox name=check[] value=1>

<p>Entry Three
<input type=text name=name[]>
<input type=text name=tel[]>
<input type=checkbox name=check[] value=1>

<p>Entry Four
<input type=text name=name[]>
<input type=text name=tel[]>
<input type=checkbox name=check[] value=1>

<p>Entry Five
<input type=text name=name[]>
<input type=text name=tel[]>
<input type=checkbox name=check[] value=1>

.

i want to process entries only with checked checkbox

how can i do this in php?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to