Re: Variable variables ! - help
| From: | Russ Michell | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Variable variables ! - help | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7445@lists.php.net to get a copy of this message | ||
Hi there:
Not sure this'll work but it's some way towards it I would think:
(Note all occurances of the variable: '$display_this'
//Start off the display item outside the loop
$display_this = "<form>";
if ($art_nr1 != '') {
$i++;
$display_this .= "
<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 != "") {
//Continue 'building up the varuable:
$display_this .=
"<input type=hidden name=\"art_nr\" value=\"$art_nr_$i\">
<input type=hidden name=\"quantity\" value=\"$quant$i\"> ";
}
endfor;
//Echo thwe variable to the page
<?php echo"$display_this"; ?>
#-------------------------------------------------------#
"Believe nothing - consider everything"
Russ Michell
Anglia Polytechnic University Webteam
http://gertrude.sipu.anglia.ac.uk/webteam
r.j.michell@anglia.ac.uk
+44 (0)1223 363271 ext 2331
www.theruss.com
#-------------------------------------------------------#