FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » using same variable twice on same page
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: using same variable twice on same page [message #171194 is a reply to message #171191] Wed, 29 December 2010 06:56 Go to previous messageGo to previous message
Adrienne Boswell is currently offline  Adrienne Boswell
Messages: 25
Registered: October 2010
Karma:
Junior Member
Gazing into my crystal ball I observed richard <member(at)newsguy(dot)com>
writing in news:yzhlacpa809x(dot)dlg(at)evanplatt(dot)sux:

> Everything I have looked at so far talks of how to use one variable
ONCE!
> Nothing I've seen even comes to close as to how to utilize the same
> variable in a different location on the same page.

I think you have HTML and PHP mixed up. You cannot use the an ID more
than once in an HTML page, class yes. For variables, you do say:

<?php

if(isset($_GET['year']))
{$year = $_GET['year'];
//do some testing to make sure the value is what you want}
else
{$year = 1960;}

echo "<p>The initial year is ".$year.".</p>";

echo "<p>Loop 10 years:</p>";

for($i=0;$i<10;++$i)
{
echo "<p>The year is now ".$year+$i.".</p>";
}
?>

>
> for instance:
> initial value of $year="1960"
> <div> <?php echo $year;?></div>
> <div> blah blah blah </div>
> <div> yada yada yada </div>
> Assume here we change $year to be "1961"
> <div> <?php if ($year="1961") echo $year; ?></div>
>
> From what I've tried, no change is made.
> Even if I use a second instance of $_GET().

$_GET(variable) does not work. You need $_GET[variable].

>
> What is the best way of doing what I want to happen?
>
> As you know, google is a hodge podge for looking up something with more
> than one word in the search bar.
>

Did you ever think about using the source, PHP.net?

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: AND in the if statement
Next Topic: login script using file, not mysql
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 17:06:16 GMT 2024

Total time taken to generate the page: 0.04834 seconds