Showing results based on a single record, info1 in images

2 posts by 2 authors in: Forums > CMS Builder
Last Post: August 8, 2013   (RSS)

Hi Crazyfish,

If you only want to return image results the easiest method would be to use a mysql_select function to search the uploads table directly, and only let it return images from the 5 galleries, something like this would work:

<?php
  $images = mysql_select('uploads', "`tableName` IN ('{$peopleRecords['_tableName']}') AND `fieldName` = 'images' AND `info2` LIKE '%Rwanda%'");
?>

<?php  foreach($images as $upload): ?>
  <div class="block">
    <a href="<?php echo $SETTINGS['uploadUrl'].$upload['urlPath'] ?>" rel="prettyPhoto[gallery1]">
      <img src="<?php echo $SETTINGS['uploadUrl'].$upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
    </a>
    <br/>
    <br/>
  </div>
<?php endforeach; ?>

This is just example code, so you might have to make a few changes to get it working. 

So the mysql_select function just searches the uploads table, and returns the results in an array. I've added a MySQL statement that will only return results from the people section (although I've used an IN statement, if you want to search other sections at the same time, add the tablenames in comma seperated strings inside the brackets). 

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com