Jump to content

how to get a value from variable?


shyami

Recommended Posts

Hi,

 

        i am generating text boxes randomly in one page,

 

  after press submit button, i am getting value in 2nd page.

 

for that in 2nd page i wrote like this

    for($i=0;$i<50;$i++)

    {

      $val="$text".$i;

      echo $val          //=>  $text1  (name of the text box)

      echo $text1        //=> it is giving correct value

    }

              when i am giving directly echo $text1, then i am getting correct value.

 

            but this $val is having my text box name, if i am giving echo $val, it is just printing the name of the text box. i need to print the value of the textbox. how to do this?

 

 

plz help me in this.

 

 

Thanks

 

Shyami

 

Link to comment
https://forums.phpfreaks.com/topic/43794-how-to-get-a-value-from-variable/
Share on other sites

Hi Shyami,

 

Following on from Lumio's post, it might help you to declare the value of $val in a variable of it's own first. Try this:

 

<?php
$getvalue = $_POST[$val];
// Now you should be able to retrieve the text box contents by:
echo $getvalue;

     for($i=0;$i<50;$i++)
     {
      $val="$text".$i;
      echo $val           //=>  $text1   (name of the text box)
      echo $text1        //=> it is giving correct value 
     }
?>

 

Post again if you still have problems.

Regards,

Iceman

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.