Trying to read the value of a var...

From: Date: Fri, 09 May 2003 19:55:36 +0000
Subject: Trying to read the value of a var...
Groups: php.general 
Request: Send a blank email to php-general+get-147066@lists.php.net to get a copy of this message
I am dynamically creating a variable in a form like this: <? $name= "quantity_"; $name.= $search_result['conference_component_cd']; ?> Quantity: <INPUT TYPE="text" NAME="<? echo $name?>" SIZE="1" MAXLENGTH="5" VALUE="<? if ($notall == 1){ echo $$name;} ?> This seems to work - when I submit the form, if 'notall' of the fields are filled in, the correct value is displayed. However, when all fields are correct and I go to insert it into the database, I don't get the correct value: while ($search_result = mysql_fetch_array($search_results)) { $name2 = "quantity_"; $name2 .= $search_result['conference_component_cd']; ?><BR><? echo $$name2; //HERE, the correct value displays if ($$name2){ $query2 = "INSERT INTO customer_conference_t "; $query2 .= "(customer_conference_cd, customer_id, conference_component_cd, quantity) "; $query2 .= " values('','$customer_id', $search_result[conference_component_cd], $$name2)"; echo $query2;?><BR><? //Here, it displays like this //$quantity_10 // mysql_query($query2) or die("Insert Failed!"); } }

« previous php.general (#147066) next »