选定的查询结果放置在更多DIV中

Im trying to select 3 testimonials at a stretch from the database.. It is ok for me. But my problem is I need place this 3 testimonials in 3 DIVs in the same time.. can anybody tell me how can I do this?

    $q = "SELECT * FROM testimonials ORDER BY RAND() LIMIT 1";
        $r = mysqli_query($dbc, $q);

   while ( $row = mysqli_fetch_array($r, MYSQL_ASSOC) ) {


   }

 echo '<div class="testimonial-1">
                   <p>'. $testimonial. '</p>
                  </div>';

 echo '<div class="testimonial-2">
                   <p>'. $testimonial. '</p>
                  </div>';

 echo '<div class="testimonial-3">
                   <p>'. $testimonial. '</p>
                  </div>';

Thank you..

I am not very familiar with mysqli since iam still using mysql..but i can still give you my personal approach regarding your question:

$class_ctr = 1;
while ( $row = mysqli_fetch_array($r, MYSQL_ASSOC) ) {
    echo '<div class="testimonial-'.$class_ctr.'">
        <p>'. $row['column_name_to_display']. '</p>
    </div>';
    $class_ctr++;
}
?>

Hope this gives you the idea.

$maxTestimonials = 3;
$query = "SELECT * FROM testimonials ORDER BY RAND() LIMIT $maxTestimonials";
$results = mysqli_query($databaseConnection, $query);

$count = 0;
$testimonialsTemplate = '<div class="testimonial-%d"><p>%s</p></div>';
while ($row = mysql_fetch_array($results, MYSQL_ASSOC))
{
    $count++;
    echo sprintf($testimonialsTemplate, $count, $row['column_name_to_display']);
}

I'd also suggest you look into separation of concerns and Model-View-Controller which will help you to structure your code in a slightly more maintainable (and reusable) fashion.