Jump to content

[SOLVED] Variable Variable name


Creech

Recommended Posts

first sry for my bad english  ::)

 

<input type="text" name="menge<?PHP echo $i ?>" value="<?php  echo $menge{$i}; ?>">

 

this code is in a loop

 

as you see i'm creating a name for that inputbox with a variable number creating with a loop 0 to x

 

so the name is menge0 menge1 menge2 and so on

as value i want $menge0 $menge1 ...

 

but i don't get it to work...

i just can't figure out how to creat a variable $menge with a variable number at the end...

like $variable$i

 

maybe someone can help me

 

ty

Creech

 

Link to comment
Share on other sites

first sry for my bad english  ::)

 

<input type="text" name="menge<?PHP echo $i ?>" value="<?php  echo $menge{$i}; ?>">

 

this code is in a loop

 

as you see i'm creating a name for that inputbox with a variable number creating with a loop 0 to x

 

so the name is menge0 menge1 menge2 and so on

as value i want $menge0 $menge1 ...

 

but i don't get it to work...

i just can't figure out how to creat a variable $menge with a variable number at the end...

like $variable$i

 

maybe someone can help me

 

thank you

Creech

 

 

instead of $menge{$i} use $menge.$i

Link to comment
Share on other sites

 

instead of $menge{$i} use $menge.$i

that does not work i get nothing in return...

 

i try to use the other hint's but until now no  :o

 

<?

for ($i=0; $i<$number; $i++){

?>
<p>Menge: 
  <input type="text" name="menge<?PHP echo $i ?>" value="$menge0"> 

<?php } ?>

 

i just try again to explain ^^

the page is loaded... the name is created

now i want the name as a variable into the value part

so that after reloading the page that what was typed into the inputbox apears again...

 

anything else that could help to understand my problem?

 

ty

Creech

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.