Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

remembering a passed through variable

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

remembering a passed through variable

Postby -[Bl@de Runner]- » Sat Aug 17, 2002 3:13 am

Hi guys,

I pass, with the URL, a variable through to a page in my site.
Let's call the variable 'index'.

In that page a submit happens when you press a button.
And then, when you press that button, I want to use that variable, but at that point the variable is 0.

How can I store this variable somewhere so that when I press the submit button, it still knows the value of the variable ?
-[Bl@de Runner]-
New php-forum User
New php-forum User
 
Posts: 9
Joined: Sun Jun 30, 2002 6:45 am

Postby Jay » Sat Aug 17, 2002 4:44 am

Store it as a cookie or session value, or if you've got a form that you're using, store it as a hidden field in that form!
Jay
 

Postby -[Bl@de Runner]- » Sat Aug 17, 2002 5:13 am

Like this ?

<input name="forumIndex" type="hidden" value="$fIndex">

Cause when I type this:

echo "$forumIndex";

It gives me the following result: $fIndex which is wrong
-[Bl@de Runner]-
New php-forum User
New php-forum User
 
Posts: 9
Joined: Sun Jun 30, 2002 6:45 am

Postby -[Bl@de Runner]- » Sat Aug 17, 2002 5:22 am

its ok, i got it :-)


i did it with : value="<?php echo "$fIndex"; ?>"
-[Bl@de Runner]-
New php-forum User
New php-forum User
 
Posts: 9
Joined: Sun Jun 30, 2002 6:45 am

Postby Jay » Sat Aug 17, 2002 11:13 am

-[Bl@de Runner]- wrote:its ok, i got it :-)
i did it with : value="<?php echo "$fIndex"; ?>"

You could just do value="<?=$fIndex?>"
Jay
 

Postby WiZARD » Sat Aug 17, 2002 11:59 am

Jay wrote:[quote="-[Bl@de Runner]-"]its ok, i got it :-)
i did it with : value="<?php echo "$fIndex"; ?>"

You could just do value="<?=$fIndex?>"[/quote]
Hi interesting whats is mean "=" in your script, - never use this....
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby Jay » Sat Aug 17, 2002 12:53 pm

WiZARD wrote:Hi interesting whats is mean "=" in your script, - never use this....

It's take from ASP I believe. It just means to output quickly, an alternative to echo or write! Very good for writing small scripts, and you can even use it with functions, eg:
value="<?=$url.$page.urlencode($someVariable)?>"

Or even:

value="<?=($value)? "Yes":"No"?>"

You just use it for single line scripts!
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.