Jump to content

Need help getting variable from array


monkeybidz

Recommended Posts

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='';

Link to comment
https://forums.phpfreaks.com/topic/76012-need-help-getting-variable-from-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.