Display results from different sections
14 posts by 2 authors in: Forums > CMS Builder
Last Post: October 27, 2010 (RSS)
Hi Chris
The array section for the dates didn't work, so created a seperate editor for the days, so still need to work out how to "group the results". Any ideas would be great.
However, this search is not pulling across all of the data. It's pulling across the "tours" section, but not the escorted, polar or river cruises. Do I need to add something to the results page to get this to display as well? Here's the header code:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/clientdata/zeus-dynamic-1/a/c/activetravel.com.au/www/','','../','../../','../../../');
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($toursRecords, $toursMetaData) = getRecords(array(
'tableName' => 'tours',
'allowSearch' => '0',
));
// load records
list($escorted_toursRecords, $escorted_toursMetaData) = getRecords(array(
'tableName' => 'escorted_tours',
'allowSearch' => '0',
));
// load records
list($polar_toursRecords, $polar_toursMetaData) = getRecords(array(
'tableName' => 'polar_tours',
));
// load records
list($river_cruisesRecords, $river_cruisesMetaData) = getRecords(array(
'tableName' => 'river_cruises',
));
But then how do I deal with the "php for each" statement, ie... <?php foreach ($river_cruisesRecords as $record): ?> and <?php foreach ($escorted_toursRecords as $record): ?>
... do I need to add these somehow? The page they all need to be summarised to is http://acac6262.staging-zeus.netregistry.net/tours_summary.php?country_list=India&type_of_holiday=&length_of_trip=&submit=View+trips but that's only showing more than a dozen times???
Terribly stuck! I have attached the summary page code as a text file if that helps.
The array section for the dates didn't work, so created a seperate editor for the days, so still need to work out how to "group the results". Any ideas would be great.
However, this search is not pulling across all of the data. It's pulling across the "tours" section, but not the escorted, polar or river cruises. Do I need to add something to the results page to get this to display as well? Here's the header code:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/clientdata/zeus-dynamic-1/a/c/activetravel.com.au/www/','','../','../../','../../../');
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($toursRecords, $toursMetaData) = getRecords(array(
'tableName' => 'tours',
'allowSearch' => '0',
));
// load records
list($escorted_toursRecords, $escorted_toursMetaData) = getRecords(array(
'tableName' => 'escorted_tours',
'allowSearch' => '0',
));
// load records
list($polar_toursRecords, $polar_toursMetaData) = getRecords(array(
'tableName' => 'polar_tours',
));
// load records
list($river_cruisesRecords, $river_cruisesMetaData) = getRecords(array(
'tableName' => 'river_cruises',
));
But then how do I deal with the "php for each" statement, ie... <?php foreach ($river_cruisesRecords as $record): ?> and <?php foreach ($escorted_toursRecords as $record): ?>
... do I need to add these somehow? The page they all need to be summarised to is http://acac6262.staging-zeus.netregistry.net/tours_summary.php?country_list=India&type_of_holiday=&length_of_trip=&submit=View+trips but that's only showing more than a dozen times???
Terribly stuck! I have attached the summary page code as a text file if that helps.
Re: [degreesnorth] Display results from different sections
By Chris - October 25, 2010
Hi degreesnorth,
Can you explain what you mean by "group the results"? What are the results you're getting now and what would grouped results be?
I also don't understand what you mean by "pulling across all of the data".
What exactly do you want to add to your results page?
Yes, you'll need to add those. Taking a look at your attached page, I can see what's going wrong:
You don't want to do that — that's called a nested loop. You'll want to do this instead:
Alternately, you can "merge" your arrays so you can use a single foreach:
You can add all your record sets into the array_merge call:
Does that help?
Can you explain what you mean by "group the results"? What are the results you're getting now and what would grouped results be?
I also don't understand what you mean by "pulling across all of the data".
Do I need to add something to the results page to get this to display as well?
What exactly do you want to add to your results page?
But then how do I deal with the "php for each" statement, ie... <?php foreach ($river_cruisesRecords as $record): ?> and <?php foreach ($escorted_toursRecords as $record): ?>
... do I need to add these somehow?
Yes, you'll need to add those. Taking a look at your attached page, I can see what's going wrong:
<?php foreach ($toursRecords as $record): ?>
<?php foreach ($escorted_toursRecords as $record): ?>
... record display code ...
<?php endforeach ?>
<?php endforeach ?>
You don't want to do that — that's called a nested loop. You'll want to do this instead:
<?php foreach ($toursRecords as $record): ?>
... record display code ...
<?php endforeach ?>
<?php foreach ($escorted_toursRecords as $record): ?>
... record display code ...
<?php endforeach ?>
Alternately, you can "merge" your arrays so you can use a single foreach:
<?php $mergedRecordSets = array_merge($toursRecords, $escorted_toursRecords) ?>
<?php foreach ($mergedRecordSets as $record): ?>
... record display code ...
<?php endforeach ?>
You can add all your record sets into the array_merge call:
<?php $mergedRecordSets = array_merge($toursRecords, $escorted_toursRecords, $polar_toursRecords, $river_cruisesRecords) ?>
<?php foreach ($mergedRecordSets as $record): ?>
... record display code ...
<?php endforeach ?>
Does that help?
All the best,
Chris
Chris
The last string of code works a dream. Thanks!
So, just one last question to solve this section... the array for grouping the days. The days are currently in a section editor, with the 'days' field each a seperate file from 1 to 30. If I need to group these into:
- any/all (ie, not important)
- 1 to 5 days
- 5 to 10 days
- 10 to 15 days
- 15 to 20 days
- 20 to 25 days
- more than 25 days
How would I go about doing this?
So, just one last question to solve this section... the array for grouping the days. The days are currently in a section editor, with the 'days' field each a seperate file from 1 to 30. If I need to group these into:
- any/all (ie, not important)
- 1 to 5 days
- 5 to 10 days
- 10 to 15 days
- 15 to 20 days
- 20 to 25 days
- more than 25 days
How would I go about doing this?
Re: [degreesnorth] Display results from different sections
By Chris - October 27, 2010
Hi degreesnorth,
I think you'll want to use the [url http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html]_min and _max search suffixes.[/url]
For example, you could put this at the very top of your script (before your getRecords()):
Does that help?
I think you'll want to use the [url http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html]_min and _max search suffixes.[/url]
For example, you could put this at the very top of your script (before your getRecords()):
$days = @$_REQUEST['number_of_days'];
delete $_REQUEST['number_of_days'];
if ($days == '1 to 5 days' ) { $_REQUEST['number_of_days_min'] = 1; $_REQUEST['number_of_days_max'] = 5; }
if ($days == '5 to 10 days' ) { $_REQUEST['number_of_days_min'] = 5; $_REQUEST['number_of_days_max'] = 10; }
if ($days == '10 to 15 days' ) { $_REQUEST['number_of_days_min'] = 10; $_REQUEST['number_of_days_max'] = 15; }
if ($days == '15 to 20 days' ) { $_REQUEST['number_of_days_min'] = 15; $_REQUEST['number_of_days_max'] = 20; }
if ($days == '20 to 25 days' ) { $_REQUEST['number_of_days_min'] = 20; $_REQUEST['number_of_days_max'] = 25; }
if ($days == 'more than 25 days') { $_REQUEST['number_of_days_min'] = 26; }
Does that help?
All the best,
Chris
Chris