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 #171201 is a reply to message #171197] Wed, 29 December 2010 13:19 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 12/29/2010 6:25 AM, Thomas 'PointedEars' Lahn wrote:
> Adrienne Boswell wrote:
>
>> richard [wrote]:
>>> Everything I have looked at so far talks of how to use one variable
>> ONCE!
> ^^
> Please get a decent newsreader that does not produce broken quotes.
>

There is nothing wrong with his newsreader. If you see broken quotes,
you need to check YOUR newsreader.

>> […]
>> <?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>";
>> }
>> ?>
>
> The following might be slightly less confusing, and slightly more efficient:
>
> <?php
> $year = (isset($_GET['year'])) ? $_GET['year'] : 1960;
>
> /* do some testing to make sure the value is what you want */
> ?>
>
> <p>The initial year is<?php echo $year; ?>.</p>
>
> <p>Loop 10 years:</p>
>
> <?php
> for ($i = $year, $maxYear = $year + 10;
> $i< $maxYear;
> ++$i)
> {
> ?><p>The year is now<?php echo $i; ?>.</p><?php
> }
> ?>
>
>
> PointedEars

Which does not answer richard's question. But that's pretty normal for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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: Tue Nov 26 13:55:10 GMT 2024

Total time taken to generate the page: 0.10924 seconds