[thelist] http://www.orchardsweb.com/webmail/

shawn allen shawn at alterior.net
Wed Oct 30 11:30:01 CST 2002


quoth 1976 design:
> I originally inserted the unique $imageid vaalue after each field
> name, so:
>
> <input type="text" size="2" maxlength="2" name="$size1$imageid"
> value="$size1" />

That's not so pretty. Are you parsing variable names to get data?
Because it would be a lot easier (client-side scripting problems aside)
for you to name your arrays like so:

<input type="text" size="2" name="rows[<?=$imageid=?]['size1']"
value="<?=$size1=?>" />

So that when you submit the form, you'll get an array like:

$_POST['rows'] = array(
	'your_image_id' => array(
		'size1'		=> 'size1_value',
		...
	),
	...
)

> If that satisfies your unique naming of each field requirement, could
> you possibly tell me two things please:
>
> [1] If I'm not using the [] how do I pass this stuff to an array? I've
> only found examples using the [] method.

Using the bare '[]' at the end of a variable name is like using it
within PHP code:

$foo[] = 'bar';

Which just assigns the string 'bar' to the next integer index of array
$foo. Associative arrays are much more easy to work with in dynamic
forms like this, since you *know* where your data will be when you get
it in the request. $foo would be much more predicable if we assign
values to it using specific keys like so:

$foo['bar'] = 'baz';

> [2] It's all useless without getting that $imageid variable into the
> array for each row... any ideas on that?

Try my example above. :)

--
shawn allen
  e: shawn at alterior.net
  p: 415 577 3961
  im: shawnpallen



More information about the thelist mailing list