[thelist] Multiple form entries in PHP...

Ray Hill lists at prydain.com
Fri Nov 30 05:49:25 CST 2001


> eg. ?field=1&field=2&field=3
>
> what does PHP do with all the values? All I can get is the last one?

When you pass variables through the URL like that, it's essentially
the equivalent of setting those variables at the top of the page.  So
your above example would be the equivalent of:

  <?
  $field = 1;
  $field = 2;
  $field = 3;
  ?>
  <!-- actual file contents starts here -->

Since you're resetting the value of the same vatriable each time, it
makes sense that you're only able to see the value of the last one,
since that's the value of the variable at the time the rest of the
page loads.

If you want to pass multiple values, you'll either have to pass them
in as seperate variables (ie. ?field1=foo&field2=bar&field3=buh), or
use checkboxes in a from post instead of passing them in the URL, as I
believe checkboxes are the only type of form field that allow multiple
values to be submitted in asociation with the same form name.



--ray






More information about the thelist mailing list