Re: [chris] Listing Records that have Multiple Category Options
Chris,
I've racked my brains over this and can't seem to figure this out. Here's what I'm trying to do. I've got a Media/Photo Gallery ($media_gallery) that has Categories ($media_categories) pulled in from a section field using the advanced option and I've also created a Date field for the Media/Photo Gallery ($media_gallery) section so when I upload new photos or media to the Media/Photo Gallery I can assign a Date value to the media and/or photos.
In the form below I have two drop down menus to allow site visitors to drill down on the media and photos by Category and/or Date.
The Category search filter is working fine, but for my Date drop down search filter, I'm getting repeating dates such as 2009, 2009, 2010, 2010, 2010... basically a date for each photo of media item that has been uploaded.
I'm trying to trim the date results in the Date drop down menu so that it only displays one 2009, 2010, 2011, and so on. So when someone chooses the Date filter and selects a Year, it returns all results for media and photos uploaded for the year selected. And/Or if the site visitor chooses a Category filter and a Date filter, it would return results for the Category chosen based on the Date filter selected.
Can you shed some light on this and what I need to do to get this working?
Thanks Zick
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'abcsite/lib/viewer_functions.php';
$dirsToCheck = array('/home/content/a/b/c/site/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load records
list($media_galleryRecords, $media_galleryMetaData) = getRecords(array(
'tableName' => 'media_gallery',
'perPage' => '9',
));
// load records
list($media_categoriesRecords, $media_categoriesMetaData) = getRecords(array(
'tableName' => 'media_categories',
));
<div id="media_search">
<!-- search filter -->
<!-- search media category filter -->
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<select name="gallery_categories_query">
<option value="">categories</option>
<?php foreach ($media_categoriesRecords as $categoryRecord): ?>
<option value="<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></option>
<?php endforeach ?>
</select>
<!-- search media date filter -->
<select name="date_query">
<option value="">Year</option>
<?php foreach ($media_galleryRecords as $record): ?>
<option value="<?php echo date("Y", strtotime($record['date'])) ?>"><?php echo date("Y", strtotime($record['date'])) ?></option>
<?php endforeach ?>
</select>
<input name="submit" type="submit" class="button" value="begin">
</form>
<!-- /search filter --></div>