Jump to content

How I modify this php while loop?


thara

Recommended Posts

I am trying to display some images dynamically from a mysql table.

 

This is what  I tried it with PHP and its working for me. 

// Fetch all the records:
while ($stmt->fetch()) {

    $html  = "  <div class='row-fluid custom'>\n";
    $html .= "      <div class='span6'>\n";
    $html .= "      <img src='images/{$image}'>\n";
    $html .= "      </div>\n";                                                              
    $html .= "  </div>\n";

    //Add images to array
    $images[] = $html;              
}

And this is the markup from about PHP: 

<div class='row-fluid custom'>
    <div class='span6'>
        <img src='images/cond-1.png'>
    </div>                                                                  
</div>  
<div class='row-fluid custom'>
    <div class='span6'>
        <img src='images/cond-2.png'>
    </div>                                                                  
</div>  
<div class='row-fluid custom'>
    <div class='span6'>
        <img src='images/cond-3.png'>
    </div>                                                                  
</div>  
<div class='row-fluid custom'>
    <div class='span6'>
        <img src='images/cond-4.png'>
    </div>                                                                  
</div>

But my problem is, now I need to modify above Markup to like this.

    <div class="row-fluid custom">
        <div class="span6">
            <img src="images/cond-1.png">
        </div>                                  
        <div class="span6">
            <img src="images/cond-2.png">
        </div>                                  
    </div>                              
    <div class="row-fluid custom">
        <div class="span6">
            <img src="images/cond-3.png">
        </div>                                  
        <div class="span6">
            <img src="images/cond-4.png">
        </div>                                  
    </div>

Can anybody tell me how I create like that markup using php?

Hope somebody may help me out.

Thank you.
 

Link to comment
https://forums.phpfreaks.com/topic/297122-how-i-modify-this-php-while-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.