Forum Moderators: coopster

Message Too Old, No Replies

Another variable question

         

kkrumlia

5:33 pm on Jun 17, 2003 (gmt 0)

10+ Year Member



Hello there

MY question i have a variable the name of it is
it48, the it is always constant the 48 changes according to a variable hence it's declared in a form and submitted.

echo "<input type=\"text\" name=\"it$CCI\" size=\"5\" value=\"$CIQ\">";

now to get it back i can get the $CCI but don't know how to use the variable name in a way to give me the $CIQ

tried
$(it$k) $k gives me CCI it's from a database
and other stuff
in other words i want it to show $it48 to get the $CIQ

jatar_k

5:39 pm on Jun 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



wow, that is really confusing.

is this what you need?

${"it" . $k}

bonanza

5:47 pm on Jun 17, 2003 (gmt 0)



Try:

$newvar = "it" . $k;
echo $$newvar;

[edit]Rats, jatar_k beat me to the punch. With shorter code, to boot.[/edit]

kkrumlia

6:25 pm on Jun 17, 2003 (gmt 0)

10+ Year Member



Guys both examples given do not work the only thing that works which is not the way i want it is
echo "$it48";
jatar_k your example looks legitimate but still gives me junk when i execute same bonanza.

To explain more i have a shopping cart, when u buy something u get the product in there where the quantity is changeable so the customer can change the amount requested then hits the Update button to update the quantites
what i am doing is with each fetch from db i submit

echo "<input type=\"text\" name=\"it$CCI\" size=\"5\" value=\"$CIQ\">";

CCI is different for each row in db

after it's done and when update is hit i reiterate over the db and uppdate the quantity in the database by putting the $it... var in it , well that's what it is supposed to do. Hope the explenation was more helpful

kkrumlia

6:31 pm on Jun 17, 2003 (gmt 0)

10+ Year Member



My mistake guys , both ur code work thanks for the help