Hi cricket7475,
I'm going to give this one a try. If this post doesn't solve it please attach some of the viewer files and/or post some more example urls so we can get a better idea. Thanks!
All the multi value fields are stored in a tab separated format. So if you had 1, 2, and 3 selected it would be stored as "\t1\t2\t3\t" (where \t means tab).
Here's how you match a single value in MySQL:
'where' => " colors LIKE '%\t
red\t%' ",
And in PHP:
<?php if (preg_match("/\t
red\t/", $record['colors']): ?>
Also, when comparing values in PHP we sure to use two == for comparison, as one = means assign the value.
$record['application'] =
= $applicationsRecord['num'])
Otherwise it will return true all the time if the assigned value isn't 0.
When you want to show related records on a detail page, all you have is the record you've already loaded, so you have to use those values to decide what to lookup, or add fields if needed to the original record to indicate what related records should be displayed with it.
For example, something like this. A detail page that shows a specific record and loads related records (untested code):
// load selected document
list($selectedDocuments, $selectedDocumentsMetaData) = getRecords(array(
'tableName' => 'documents',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$selectedDocument = @$selectedDocuments[0]; // get first record;
// load related documents
list($relatedDocuments, $relatedDocumentsMetaData) = getRecords(array(
'tableName' => 'documents',
'where' => " colors LIKE '%\t" .mysql_escape(@$selectedDocument['color']). "\t%' ",
'allowSearch' => false,
'limit' => '1',
));
It helps make a lot more sense when you rename the variables. Now I have the selected record that I can show like this: <?php echo $selectedDocument['title'] ?> and I can use foreach to loop over the related records.
On individual applications pages (which are generated from a 'multi' menu type) , I want to show the specific document type of 'application note', and documents which have the same application as the application page I'm viewing (i.e. surface water application notes on the surface water application page). // for your related records use something like:
'where' => " document_type = '1' ", // 1 == application note
And here's what it gets tricky, the pages you're viewing can have multiple applications values right?
If it's a single value then you can just add to the where:
AND 'application' = '' .mysql_escape($selectedDocument['application']). ''
But if it can have multiple values then you need to generate some SQL like this:
'application IN ('value1','value2','value3','etc').
Let me know if you need that and I'll write you some code for that. Working with multi value fields is a little tricky sometimes.
Hope that helps! Let me know any further questions or details you need.
Dave Edis - Senior Developer
interactivetools.com