CodeIgniter Forums
Displaying query results with image thumbnails - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Displaying query results with image thumbnails (/showthread.php?tid=29226)



Displaying query results with image thumbnails - El Forum - 04-02-2010

[eluser]viisik[/eluser]
How to display a select query if there is needed to display the list of items with thumbnails of images corresponding to each item , images linking to larger images

for example - search lists the houses for sale

where each house in the list includes 4 thumbnail images of each house ,
the thumnail images link to larger images


Displaying query results with image thumbnails - El Forum - 04-03-2010

[eluser]zimco[/eluser]
I did something similar only i needed to display just one thumbnail for each item, but i would think nesting a loop inside an outer loop would get you more than one. Anyhow in my view file to display the search results with a thumnail i did this:

Code:
<?php
if ($num_rows != 0) {
    $i=0;
    while($i < $num_rows) { ?&gt;
    <dl>
    <dt class="prog_title">&lt;?php echo $output[$i]['title']; ?&gt; <span>courtesy of &lt;?php echo $output[$i]['upld_by_username'];?&gt;</span></dt>
    &lt;?php //check to see if thumb is there, if not display default thumbnail
if (file_exists( $_SERVER{'DOCUMENT_ROOT'} ."/mycontroller/img_folder/".$output[$i]['upld_by_username']."/thumbs/".$output[$i]['orig_name']."_thumb.jpg") ) { ?&gt;
    <dd class="image"><img src="&lt;?php echo " alt="" width="42" height="58" /></dd>
    &lt;?php } else { ?&gt;
    <dd class="image"><img src="./images/blankcover.png" alt="" width="42" height="58" /></dd>
    &lt;?php } ?&gt;
    <dd>&lt;?php echo date( 'Y-M-d,D, g:i A', strtotime($output[$i]['prog_date']) ); ?&gt;  <a href="&lt;?php echo site_url('readbook/online/' . $output[$i]['pdf_id']); ?&gt;"> READ ONLINE </a></dd>
    <dd>(&lt;?php echo $output[$i]['abbrv'];?&gt;) &lt;?php echo $output[$i]['name'];?&gt; &lt;?php echo $output[$i]['state'];?&gt; &lt;?php echo $output[$i]['country'];?&gt;</dd>
    </dl>
    &lt;?php //Increment the while loop count
    $i++;
    } //end while
} else {
    echo "SORRY, NO RESULTS RETURNED.";
}
?&gt;