Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
AYK
Hangin' Around



Joined: Apr 03, 2004
Posts: 32

PostPosted: Tue Apr 06, 2004 4:03 am Reply with quote

I'm teaching myself PHP & MYSQL so beware of my high noob level at this, but I ran into this problem :
This code is in a form and in a cell of a table:

Code:
 for ( $i=8; $i<$numfields; $i++ ) 

       {
        $input = "inp_$i";
        <input type=text name=$input size=2 value=0>               
       }


- I deleted some non-interesting stuff - ok so now this loop creates :
inp_8, inp_9 ............... inp_17 or so.

when I submit the code, this information is available :
inp_8 and $inp_8 ( the value of inp_8 )
this is true, I tested it.

But now I want to make this :
Code:
 for ( $i=8; $i<$numfields; $i++ ) 

       {
                echo $(inp_$n);             
       }


but I cannot get that to work ! I've been trying all morning with the variable-variables were :
$input = inp_$i;
$$input = $($input);

but that's pretty much the same problem.

Any clues ?
 
View user's profile Send private message Visit poster's website
AYK







PostPosted: Tue Apr 06, 2004 4:58 am Reply with quote

Oops, found it out myself :

this is the solution :
Code:
$input = "inp_$i";

echo "$ {$input}";
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Apr 06, 2004 5:31 am Reply with quote

Yep! I would remove the space though
Code:
echo "${$input}";
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©