Re: Variable variables ! - help
| From: | Keith Whyman | Date: | Wed, 14 Mar 2001 13:07:12 +0000 |
| Subject: | Re: Variable variables ! - help | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7444@lists.php.net to get a copy of this message | ||
I've got a loop which includes the following coming from mySQL
if ($art_nr1 != '') {
$i++;
echo "
<td>
<input type=\"hidden\" name=\"art_nr_$1\"
value=\"$art_nr1\">
<input type=\"text\" name=\"quant$i\" size=\"3\"
maxlength=\"5\">
</td>
";
I've now got the following
art_nr_1=12456
quant1="" or 1 or so
And now comes the bit which doesn't work !
for ($i=1; $i<50; $i++) :
$varid = "quant".$i ;
if ($$varid != "") {
echo
"<input type=hidden name=\"art_nr\" value=\"$art_nr_$i\">
<input type=hidden name=\"quantity\" value=\"$quant$i\"> ";
}
endfor;
This gives the result
<input type=hidden name="art_nr" value="1">
<input type=hidden name="quantity" value="1">
which is unfortunately not what I want !
I'm sure it's easy but can someone please help !