how to get something to display only once in a while loop

Posted by Matt Nathanson on Stack Overflow See other posts from Stack Overflow or by Matt Nathanson
Published on 2010-06-02T21:19:41Z Indexed on 2010/06/02 21:24 UTC
Read the original article Hit count: 140

Filed under:
|

I've got a mysql query running and it checks to see if an iterator is equal to 1, then display this div title...

if ($this->dliterator == 1) {echo "<div class='clientsection' id='downloads'>Downloads</div><br/>";};

The problem is, is that the dl iterator may not necessarily start at 1. (it is directly related to a downloadid from the database).

How can I get this to display only for the first time through the loop ONLY?

while ($row = mysql_fetch_assoc($result)) { 

        if ($row['download'] != null){
            if ($this->dliterator == 1) {echo "<div class='clientsection' id='downloads'>Downloads</div><br/>";};


            if ($editDownload == 1) {
                echo "<div class='clientlink' style='margin-top: 15px;'>";
                echo "<input name='downloads[$this->dliterator][name]' type='text' id='download$this->dliterator' value='" . $row['download'] . "'/>";
                echo "<input name='downloads[$this->dliterator][title]' type='text' id='downloadtitle$this->dliterator' value='" . $row['downloadtitle'] . "'/>";
                echo "<img class='removelink' src='/images/deletelink.png' width='15' />";
                echo "<input id='downloadid' name='downloads[$this->dliterator][id]' type='hidden' value='".$row['downloadid']."' style='display: none'/>";
                echo "<br/><img id='uploaddownload$uploaditerator' class='uploaddownload' src='../images/upload.png' width='80'/>"; 
                echo "</div>";


            };

        };

        $this->dliterator++;

        $uploaditerator++;
        };

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql