Reply to Re: [PHP] incrementing a register global

Your name:

Reply:


Posted by "Richard Lynch" on 06/16/05 03:50

On Wed, June 15, 2005 12:43 pm, Aaron Todd said:
> I dont know it this is possible, but here it goes. Hopefully I cac
> explain
> it well enough for someone to understand.
>
> I am posting data to a php script. I have several variables that are the
> same except the number at the end is different. So the url of the called
> script will be something like:
>
> http://www.something.com/test.php?name1=Sam&name2=Bill&name3=Joe
>
> On my script I am using substr() and strrchr() to get the number of last
> variable:
>
> $names = substr(strrchr($_SERVER['QUERY_STRING'],"&"),7,1);
>
> I am then trying to run a loop to call each variable and just print it on
> the screen:
>
> for($i=1;$i<=$boxes;$i++){
> echo $_GET['name'].$i;
> }
>
> This is where my problem is. And I dont know if this is even possible,
> but
> if you look at the echo line in the loop I am trying to add the number of
> $i
> to the register global. I dont get an error in doing this, but when I run
> the script I get the number of $i instead of the value of $_GET['name1']
>
> Like I said, I hope I explained this good enough for someone to know what
> I
> am trying to do. If anyone has any suggestions or comments about doing
> something like this please let me know.

You could use variable variables, but what you REALLY should do is change
your $foo1 $foo2 $foo3 into an array of $foo[1] $foo[2] $foo[3]

It will be MUCH easier!

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация