While loop and reusing fetch_assoc()
<p>For a project I am building a flash game website, and I would like to know how to reuse this piece of code:</p>

<pre><code>        $result = $conn-&gt;query("SELECT DISTINCT `category` FROM beoordeling");

                &lt;?php
                echo "&lt;div class='row list jumbotron'&gt;";
                while($data = $result-&gt;fetch_assoc()) {

                    echo "&lt;div class='col-md-3'&gt;&lt;a href='category.php?id=" . $data['category'] . "' class='thumbnail'&gt;&lt;h4&gt;" . ucfirst($data['category']) . " games&lt;/h4&gt;";
                    echo "&lt;img src='" . $imgLocation . $data['category'].".jpg' class='img-rounded' alt='" . $data['category'] . "' width='304' heigth='182'&gt;";
                    echo "&lt;/a&gt;&lt;/div&gt;";
                }
                echo "&lt;/div&gt;";
            ?&gt;      
</code></pre>

<p>I need to be able to use the <code>$data['category']</code> again for dynamicly filling my menu with all of the games categories. If I just try to use the while loop again but then only one will work. The other one stays empty. Thanks alot!</p>