2 Replies Latest reply on May 15, 2006 8:14 AM by Newsgroup_User

    Counting to 3 in a recordset loop

    mikiekwoods
      This should be easy...

      I have a recordset that repeats using this code

      quote:

      <?php do { ?>
      &gt;
      <a href="javascript opStrict('flash/displayimage.php?album=lastup&amp;cat=0&amp;pos=0');"><?php echo substr($row_flashRS['title'], 0,32); ?></a><br />
      <?php } while ($row_flashRS = mysql_fetch_assoc($flashRS)); ?>


      I needs a variable to count from 0 to 2 so that I can print it in the link so that each of the 3 links is different.
      (I ask this because I don't know any php, maybe dreamweaver has it built in but I dunno where)
        • 1. Re: Counting to 3 in a recordset loop
          mikiekwoods Level 1
          Can someone please help?
          • 2. Re: Counting to in a record loop
            Level 7
            <?php do { ?>

            //INSERT COUNTING VARIABLE HERE
            $i

            <a
            href="javascript opStrict('flash/displayimage.php?album=lastup&amp;cat=0&amp;po
            s=0');"><?php echo substr($row_flashRS, 0,32); ?></a><br />
            <?php

            //UPDATE COUNTER HERE
            $i++
            }

            while ($row_flashRS =
            mysql_fetch_assoc($flashRS)); ?>

            And then, whenever you want your variable printer, simply put in <?php echo
            $i ?>

            > I needs a variable to count from 0 to 2 so that I can print it in the link
            > so
            > that each of the 3 links is different.
            > (I ask this because I don't know any php, maybe dreamweaver has it built
            > in
            > but I dunno where)
            >