Re: Creating variable names from values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually....you're doing it right....you just need to concatenate.

ex:

echo "<td><input *name=\"K".$key."\"*  type=\"checkbox\" ...></td>

and then later you access the values the same way...(you loop on $key and
the value would be "K".$key)...


Regards,
Rabih


On 3/8/07, Otto Wyss <otto.wyss@xxxxxxxxxx> wrote:

From an arry I create a table like

  foreach ($persons as $key => $pers) {
    echo "<td><input name=\"K$key\" type=\"checkbox\" ...></td>
          <td>...</td>
  }

so each checkbox field has its own name created from $key. Yet how can I
access these fields (names) later on?

  foreach ($persons as $key => $pers) {
    if ($K???) {
      $cnt += 1; ...
    }
  }

Is there a better way to access multiple fields from a table?

O. Wyss

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux