Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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