Jump to content

Archived

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

thara

How I modify this php while loop?

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.
 

Share this post


Link to post
Share on other sites

×
×
  • 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.