GetDotted Domains

Viewing Thread:
"Hmmm...how do I do this..."

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Mon 08/11/04 at 15:45
Regular
"Pouch Ape"
Posts: 14,499
I've got a form, with inputs of text_1, text_2, text_3 etc - generated using incrementing variable, so they won't break series. I'm then posting through to a PHP script, with also has a counter which matches up to a corresponding variable and posts that variable's data. Sound simple, but in practice nothing I do seems to be working. I've had a look at variable variables on php.net, but that didn't work. Any ideas? Oh, and I need this to be in a while loop, i.e.:

$count = 20;
while($count > 0)
{

[match up $text_20 to $count when that is 20]

$count--;

}

The problem isn't my syntax, it's actually how to get it to work!
Mon 15/11/04 at 22:18
Regular
"Eff, you see, kay?"
Posts: 14,156
Take a look at for() { } as well.
Mon 15/11/04 at 16:07
Regular
"Pouch Ape"
Posts: 14,499
Yo Garin, is there any reason why when I recover the data it's in reverse!? I'm pretty sure it's not my code.

EDIT:
Don't worry, it's just me being a mong. It's pretty obvious what I was doing wrong - one variable going up, one variable going down, I was using the wrong one! Cheers though, being able to put them variables together is really handy.
Mon 08/11/04 at 17:32
Regular
"Pouch Ape"
Posts: 14,499
Spot on, Garin, nice one!
Mon 08/11/04 at 17:27
Regular
"Pouch Ape"
Posts: 14,499
Manic's is what I tried before, but that didn't work - even though it seemed like the right thing to do. I'll try Garin's soon. Such a tiny part of the site I'm building, but essential and it's holding me up!
Mon 08/11/04 at 16:17
Regular
"Devil in disguise"
Posts: 3,151
Not sure I understand what you wanna do but how about this...

$count = 20;
while($count > 0)
{
if (isset($_POST["text_".$count])) {
$somevar=$_POST["text_".$count]);
}
$count--;
}

I think your problem is that you're relying on registered variables? ie, $text_20 being created for you when you post to the script. You shouldn't rely on this anymore, register globals is off by default in php now so eventually you're going to encounter a server that won't like your code (aside from the security risks of relying on it).
Anyway, if you just access your post data through $_POST then its easy to accomplish what you want if I understand your problem correctly.
Mon 08/11/04 at 16:14
Regular
Posts: 88
monkey_man wrote:
> $count = 20;
> while($count 0)
> {
>
> [match up $text_20 to $count when that is 20]
>
> $count--;
>
> }
>
> The problem isn't my syntax, it's actually how to get it to work!

You need to put the name of the variable you want into a string.
eg:

$myvar = 'text_'.$count;
echo $$myvar;

Then the $myvar variable gets expanded by php to be 'text_20' or whatever, and that echo line above becomes echo $text_20;

It can sometimes be clearer by using curly braces, eg:
echo ${$myvar};
Mon 08/11/04 at 15:45
Regular
"Pouch Ape"
Posts: 14,499
I've got a form, with inputs of text_1, text_2, text_3 etc - generated using incrementing variable, so they won't break series. I'm then posting through to a PHP script, with also has a counter which matches up to a corresponding variable and posts that variable's data. Sound simple, but in practice nothing I do seems to be working. I've had a look at variable variables on php.net, but that didn't work. Any ideas? Oh, and I need this to be in a while loop, i.e.:

$count = 20;
while($count > 0)
{

[match up $text_20 to $count when that is 20]

$count--;

}

The problem isn't my syntax, it's actually how to get it to work!

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Thanks!
Thank you for dealing with this so promptly it's nice having a service provider that offers a good service, rare to find nowadays.
Top-notch internet service
Excellent internet service and customer service. Top-notch in replying to my comments.
Duncan

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.