RE: [PHP-DB] INSERT prob

From: Date: Sat, 22 Sep 2001 11:45:04 +0000
Subject: RE: [PHP-DB] INSERT prob
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-12653@lists.php.net to get a copy of this message
>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 Russ, sorry I got my $key and $val mixed up in my original reply. Here's some tried and tested code: $user[0][Name] = "Betty"; $user[0][Age] = 5; $user[0][Course] = "Starters"; $user[1][Name] = "Alan"; $user[1][Age] = 29; $user[1][Course] = "Main"; while(list($key, $val) = each($user)) { echo "$val[Name]<br>"; echo "$val[Age]<br>"; echo "$val[Course]<br>"; } regards -- Jason Wong Gremlins Associates www.gremlins.com.hk Tel: +852-2573-5033 Fax: +852-2573-5851

« previous php.db (#12653) next »