Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP loop increments greater than 1

Participant ,
May 20, 2010 May 20, 2010

Hi Folks,

I am trying to get a drop down menu to populate in increments of 10 and I can't seem to get it. It must be easy but searching the net doesn't seem to get me anywhere.

here's what I have at present:

----------------------------------------------------------------

<select name="distance_miles" class="formrightcolumnnarrow" id="distance_miles">

  <?php

  for( $i=0; $i<=1000; $i++ )

{?>

<option value="<?php echo$i;?>"><?php echo$i;?>

<?php ;} ?>

  </option>

  </select>

----------------------------------------------------------------

if I do the obvious and change $i++ to $i+10 the browser hangs.

Can anyone give me a clue how to make it work for a higher increment than 1?

Cheers

Dave

TOPICS
Server side applications
2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 20, 2010 May 20, 2010

$i++ is shorthand for $i=$i+1

So....

$i=$i+10

Translate
LEGEND ,
May 20, 2010 May 20, 2010

$i++ is shorthand for $i=$i+1

So....

$i=$i+10

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 21, 2010 May 21, 2010

Great thanks,

I am truly dumb.

Cheers

Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 21, 2010 May 21, 2010
if I do the obvious and change $i++ to $i+10 the browser hangs.

Can anyone give me a clue how to make it work for a higher increment than 1?

$i++ is an abbreviation for:

  $i = $i + 1;

So, use:

  $i = $i + 10;

HTH,

Randy

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 21, 2010 May 21, 2010
LATEST

Dang, I need to refresh my list more often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines