PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
AYK
Hangin' Around


Joined: Apr 03, 2004
Posts: 32

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

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
Hangin' Around


Joined: Apr 03, 2004
Posts: 32

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

Oops, found it out myself :

this is the solution :
Code:
$input = "inp_$i";
echo "$ {$input}";
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

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

Yep! I would remove the space though
Code:
echo "${$input}";
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum