views:

44

answers:

2

Hi all, why isn't my while loop getting the mysql database entries and presenting them like demonstrated? Thanks :).

<?php $djs_all_db = mysql_query("SELECT * FROM djs")
        or die(mysql_error());      
        $djs_all_num = mysql_num_rows($djs_all_db);
        while($djs_all = mysql_fetch_array( $djs_all_db )) {
        if ($djs_all_num % "2") {
            echo "<div class=\"row\">
        <div class=\"column column-2\">
                <img src=\"images/about/" . $djs['username'] . "-profile.png\" alt=\"Profile\" class=\"profile-image\"/>

                <p class=\"float-left\"><strong>" . $djs['realname'] . "</strong></p>
                <p class=\"float-right\"><a href=\"#\" title=\"\">" . $djs['position'] . "</a></p>

                <div class=\"clear\"></div>

                <p>" . $djs['biography'] . "</p>

            </div>";
        } else {
            echo "<div class=\"column column-3\">
                <img src=\"images/about/" . $djs['username'] . "-profile.png\" alt=\"Profile\" class=\"profile-image\"/>

                <p class=\"float-left\"><strong>" . $djs['realname'] . "</strong></p>
                <p class=\"float-right\"><a href=\"#\" title=\"\">" . $djs['position'] . "</a></p>

                <div class=\"clear\"></div>

                <p>" . $djs['biography'] . "</p>

            </div></div>";
        } }?>
+3  A: 

Your loop defines: $djs_all -- In your code you use: $djs['username'], change it to $djs_all['username']

pritaeas
I really need to thank you guys over here more often. THANKYOU!!!
Sam
I think your 100% accept rate shows that you do indeed thank people.
Joubarc
A: 

Don't know if that's your issue, but

if ($djs_all_num % "2") { 

tests a static number( the number of entries in your table), so you'll always execute the if or the else part.

Also, you loop on a djsall variable:

while($djs_all = mysql_fetch_array( $djs_all_db )) {     

But you try to access fields from a $djs one:

<img src=\"images/about/" . $djs['username']
Joubarc