Jason:
Thanks for your help but it still aint working quite right!
As you suggested I now have a dynamically generated form of the following
construction:
<tr>\n\t
<td>Name:</td>\n\t
<td><input type=\"hidden\" name=\"user[$itemID][Name]\"
value=\"$Name\"><p>$Name</p></td>\n\t
</tr>\n\t
<tr>\n\t
<td>Age:</td>\n\t
<td><input type=\"hidden\" name=\"user[$itemID][Age]\"
value=\"$Age\"><p>$Age</p></td>\n\t
</tr>\n\t
//etc etc
I use a modified version of the method you showed me to extract the values and
echo to the page (so I'm sure I'm inserting the correct values) thus:
while (list($key,$val) = each($user)) {
while (list($key2,$val2) = each($val)) {
echo $val2;
}
}
/*
This displays *all* the correct info, However I am unable to extract a
*specific* entry like 'Name' for example. You suggested the following method
(Yours was from within a SQL insert statement, this is my adaptation for the
current testing situation):
*/
while (list($key,$val) = each($user)) {
while (list($key2,$val2) = each($val)) {
echo $val2[Name]; //Your method
}
}
/*
This, rather oddly, displays the first character of each result. Not the whole
of the 'Name' result. In fact putting *anything* between the square brackets
produces the same result!!
*/
Are you able to help me out any further here?
Many thanks for your efforts thus far Jason.
Russ
> I'm not sure how you are naming the variables on your form but I
> suggest
> using something like:
>
>
> <INPUT TYPE="CHECKBOX" NAME="form[0][save]" VALUE="YES">
> <INPUT TYPE="TEXT" NAME="form[0][name]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[0][address]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[0][age]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[0][course]" VALUE="blahblahblah">
>
> <INPUT TYPE="CHECKBOX" NAME="form[1][save]" VALUE="YES">
> <INPUT TYPE="TEXT" NAME="form[1][name]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[1][address]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[1][age]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[0][course]" VALUE="blahblahblah">
>
> <INPUT TYPE="CHECKBOX" NAME="form[2][save]" VALUE="YES">
> <INPUT TYPE="TEXT" NAME="form[2][name]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[2][address]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[2][age]" VALUE="blahblahblah">
> <INPUT TYPE="TEXT" NAME="form[0][course]" VALUE="blahblahblah">
>
> Now when you receive this form you'll get all the stuff you want in one
> variable, in this case $form.
>
> To insert into the database:
>
> while (list($key,$val) = each($form)) {
> if ($key[save] == "YES") {
> $insertsql = "INSERT INTO $table_user (Name,Address,Age,Course)
> VALUES ('$key[name]', '$key[address]', 'key[age]',
> '$key[course]')";
> $result = mysql_query($insertsql, $connection) or
> die(mysql_error());
> }
> }
>
>
> NB code is untested, use with caution :)
>
>
> hth
> --
> Jason Wong
> Gremlins Associates
> www.gremlins.com.hk
> Tel: +852-2573-5033
> Fax: +852-2573-5851
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]