Re: [PHP-DB] Variable variables ! - help
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; $i50; $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 ! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Variable variables ! - help
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; $i50; $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 [EMAIL PROTECTED] +44 (0)1223 363271 ext 2331 www.theruss.com #---# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Variable variables ! - help
sorry I don't think I explained that very clearly ! The first loop's on a page which works fine, and it's in a form with article numbers and then an input field for quantites ! It's the next page that's giving me headaches ! The user submitted the form with all article numbers and some with a quantity ! And on the next page I just want to display/mail the article numbers with a quantity ! 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; $i50; $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 [EMAIL PROTECTED] +44 (0)1223 363271 ext 2331 www.theruss.com #---# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Variable variables ! - help
driving me up the bloody wall ! I'm sure it's something simple ! This works fine for ($i=1; $i50; $i++) : $varid = "quant".$i ; if ($$varid != "") { echo " input type=hidden name=\"art_nr\" value=\"$art_nr_1\" input type=hidden name=\"quantity\" value=\"$quant1\" "; } but the moment I change it to $art_nr_$i it doesn't ??? sorry I don't think I explained that very clearly ! The first loop's on a page which works fine, and it's in a form with article numbers and then an input field for quantites ! It's the next page that's giving me headaches ! The user submitted the form with all article numbers and some with a quantity ! And on the next page I just want to display/mail the article numbers with a quantity ! 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; $i50; $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 [EMAIL PROTECTED] +44 (0)1223 363271 ext 2331 www.theruss.com #---# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]