RE: [PHP-WIN] assigning variable names on the fly, backed myself in to a corner

From: Date: Tue, 13 Feb 2001 22:29:27 +0000
Subject: RE: [PHP-WIN] assigning variable names on the fly, backed myself in to a corner
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-5556@lists.php.net to get a copy of this message
Oops..yep. Thanks for pointing that out...that's what I meant. Ignatius > -----Original Message----- > From: Darvin Andrioli [mailto:darvin.andrioli@caricese.it] > Sent: Tuesday, 13 February 2001 22:52 > To: 'Ignatius Teo'; 'Asendorf, John'; 'Php-Windows (E-mail)' > Subject: RE: [PHP-WIN] assigning variable names on the fly, backed > myself in to a corner > > > Ignatius wrote: > > > try assigning it to another variable first: > > for .... > > $tag = "$tag_num$i"; > > $type = "tag_type$i"; > > $sql = .... VALUES (..., $tag, $type....); > > The last statement must be: > $sql = .... VALUES (..., $$tag, $$type....); > > so you get the value of the variable named tag_type$i, > otherwise yo get only the string "tag_type value of $i" > > Darvin > > > > -----Original Message----- > > From: Asendorf, John [mailto:JAsendorf@lcounty.com] > > Sent: Tuesday, 13 February 2001 07:58 > > To: Php-Windows (E-mail) > > Subject: [PHP-WIN] assigning variable names on the fly, > > backed myself in > > to a corner > > > > > > I've written a little script that makes a form using a simple > > for loop: > > > > if ( $num_reg != "" ) { //we're doing regulars > > > > for ( $i = 1 ; $i <= $num_reg ; $i++ ) { > > echo "<tr><td>A<input type=\"hidden\" > > name=\"tag_type${i}\" > > value=\"A\"></td>"; > > echo "<td><input type=\"text\" > > name=\"tag_num${i}\"></td>"; > > echo "<td><input type=\"text\" name=\"tag_cost${i}\" > > value=\"\"></td>"; > > echo "<td><input type=\"text\" > > name=\"tag_late${i}\"></td></tr>\n"; > > } > > > > $tag_count = $num_reg; > > > > } > > > > Now what I have is a number of variables that look > something like this > > > > $tag_type1, $tag_num1, $tag_cost1, $tag_late1, $tag_type2, > $tag_num2, > > $tag_cost2, $tag_late2, etcetera... up to any number of tags... > > > > now I'm trying to write a little for loop that drops this > > information into a > > database after the POST: > > > > for ( $i=1 ; $i <= $tag_count ; $i++ ) { //tag_count came > > from the post > > (dl_post_3.php) > > > > $sql = "INSERT into cfull2.tbl_dl_tags (TAGID_NUM, > > CUSTID_NUM, TAG_NO, > > TAG_YEAR, TYPE_CODE, COST, TYPE) VALUES ($CUSTID_NUM, > > $tag_num$i, $tag_year, > > '$tag_type$i' , $tag_cost$i )"; > > > > $stmt = OCIParse ( $connection , $sql ); > > > > OCIExecute ( $stmt , OCI_DEFAULT ); > > OCICommit( $connection ); > > OCIFreeStatement ( $stmt ); > > } > > > > > > This obviously doesn't work and I'm not really sure what to > > do now. Is this > > a case of variable variable names? I don't quite get those > either :) > > > > Thanks in advance all, > > > > John > > > > > > --------------------- > > John Asendorf - jasendorf@lcounty.com > > Web Applications Developer > > http://www.lcounty.com - NEW FEATURES ADDED DAILY! > > Licking County, Ohio, USA > > 740-349-3631 > > Ipsa scientia potestas est > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > > For additional commands, e-mail: php-windows-help@lists.php.net > > To contact the list administrators, e-mail: > > php-list-admin@lists.php.net > > >

« previous php.windows (#5556) next »