Welcome Guest, Not a member yet? Register   Sign In
four images per row..how to display a title for each image right under the image??
#1

[eluser]Unknown[/eluser]
Sad I am having troubles to place an album name for each of the four albums in a row..
what i got below is the display actually comes out to be
image
title
image
tile
image
title
.
.
.

how do i code it to look like
image image image image
title title title title

image image image image
title title title title

Code:
<?php
  
      $count = 0;
   foreach ($query_listing->result() as $row) {
                 if ($count % 4 == 0)
                     echo '<tr>';
    echo " "
     . '<a href="' . ">album_id
     . '" />'
     ."<td><img src='/CodeIgniter/images/album/".$row-&gt;album_cover."' /></td><p>"
     . $row->album_name ."</p>"
     ;
     echo " ";
                    if ($count % 4 == 3)
                     echo '</tr>';
                 $count++;  }

             ?&gt;
#2

[eluser]srpurdy[/eluser]
There is no point in limiting the display to 4 per row. simply design your layout and css so 4 is all that can fit. If you force 4 per row you have some design issues later specially if you want a responsive design. Or need a mobile version. And don't use tables. They are slow.

I suggest taking a look at twitter bootstrap. Will give you a perfect example of what you want without using ugly tables. (FYI I'm not saying to never use tables) but for most things they are useless.)

And I suggest writing your code cleaner

use
Code:
&lt;?php foreach():?&gt;
html code &lt;?php echo $row->field;?&gt;
&lt;?php endforeach;?&gt;

and
Code:
&lt;?php if():?&gt;
html code &lt;?php echo $row->field;?&gt;
&lt;?php endif;?&gt;

This will make your code much more readable. you'll thank me later. Smile




Theme © iAndrew 2016 - Forum software by © MyBB