monkeybidz Posted November 5, 2007 Share Posted November 5, 2007 How would I get the name of a text field created by an array. The text fiel name is txt2. Array is txt0,txt1,txt2,txt3. if(isset($sessionVars['SELL_varval'])) { $varval=$sessionVars['SELL_varval']; } else $varval=array(); $TPL_auction_variant='<table width="100%">'; foreach($ltxt as $k=>$v) { $TPL_auction_variant.="<tr><td align='right' width='30%'><B><LABEL FOR=ntxt[$k]>$v:</LABEL></B></td>"; if(isset($values["txt$k"])) { $TPL_auction_variant.="<td><SELECT NAME='txt[$k]'>\n<OPTION VALUE=''>$MSG_25_0070</OPTION>\n"; foreach($values["txt$k"] as $kv=>$vv) { $TPL_auction_variant.="<OPTION VALUE='$kv' ".((stripslashes($varval["txt$k"])==$vv)?"SELECTED":"").">$vv</OPTION>\n"; } $TPL_auction_variant.="</SELECT></td>\n"; } $TPL_auction_variant.="<td width='100%'><INPUT type='text' value=\"".stripslashes($varval["txt$k"])."\" NAME='ntxt[$k]' /></td></tr>\n"; } foreach($lnum as $k=>$v) { $TPL_auction_variant.="<tr><td align='right'><LABEL FOR=ntxt[$k]>$v:</LABEL>($MSG_25_0073)</td>"; if(isset($values["num$k"])) { $TPL_auction_variant.="<td><SELECT NAME='num[$k]'>\n<OPTION VALUE=''>$MSG_25_0070</OPTION>\n"; foreach($values["num$k"] as $kv=>$vv) { $TPL_auction_variant.="<OPTION VALUE='$kv' ".(($varval["num$k"]==$kv)?"SELECTED":"").">$vv</OPTION>\n"; } $TPL_auction_variant.="</SELECT></td>\n"; } $TPL_auction_variant.="<td width='100%'><INPUT type='text' value=\"".$varval["num$k"]."\" NAME='nnum[$k]' /></td></tr>\n"; } $TPL_auction_variant.="</table>"; } else $TPL_auction_variant=''; Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 5, 2007 Share Posted November 5, 2007 you could use extract? http://us2.php.net/manual/en/function.extract.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.