Pulling info from database and dynamically adding them into different divs

Posted by Matt Nathanson on Stack Overflow See other posts from Stack Overflow or by Matt Nathanson
Published on 2010-04-20T16:10:45Z Indexed on 2010/04/20 16:13 UTC
Read the original article Hit count: 336

Filed under:
|

This may be a bit of a php n00b question but i've managed to get it working this far and I'm a little bit stuck. I'm pulling 12 images with descriptions out of a database. I want to insert them into a client rotator that has 3 sets of 4. They will be contained in divs called

 clientrotate1, clientrotate2, and clientrotate3 
respectively. Inside each of those divs I want to have 4 images with classes
 thumb1, thumb2, thumb3, and thumb4 
I am successful in having the images and descriptions pull into clientrotator 1. Where I get stuck is to how to dynamically add the 2nd and 3rd set of data into clientrotator2 and clientrotator3.

Here is my function:

        public function DisplayClientRotator(){

    $result = mysql_query( 'SELECT * FROM project ORDER BY id DESC LIMIT 12' )
    or die("SELECT Error: ".mysql_error());

    $iterator = 1;

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


        echo "<div id='clientrotate1'>";
        echo "<div class='thumb$iterator'>";
        echo "<img style='width: 172px; height: 100px;' src=".$row['photo']." />";
        echo "<div class='transbox'>";

        echo "<div class='thumbtext'>";

        echo $row['campaign'];
        echo "</div>";          
        echo "</div>";
        echo "</div>";
        echo "</div>";
        $iterator++;
    }

Any help or pointers int he right direction would be greatly appreciated!

Thanks so much, Matt

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql