While Loop Loading Correlating Records Issue

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 4, 2011   (RSS)

By Steve99 - January 4, 2011

Intent: To pull correlating records based on selected features

Description: The Cell Phones section editor uses a multi checkbox list to select feature options from the Features section editor (table). Instead of simply listing them out by using the CMS join with getListLabels function, my desire is to add a link for a pop up window to each item to display the Feature description content. The pop up window is set to pull the record from the number in the URL.

Issue: The 'where' condition should be set to pull the record based on the variable passed, however it is kicking back an error stating 'Unknown column VAR in where clause'. Seems to be a problem with looking up the VAR in the specified column because the error is stating the VAR as the unknown column.

Here is the code:
<?php $start_values = join(',', getListLabels('cell_phones', 'services_features', $cell_phonesRecord['services_features']));
$valuesArray = explode( ",", $start_values );
$valuesCount = count($valuesArray);
$i = 0;
while ($i < $valuesCount) {
// CORRELATING SERVICE FEATURE load records
$service_feature = mysql_real_escape_string($valuesArray[$i]);
list($servicesRecordsSF, $servicesMetaDataSF) = getRecords(array(
'tableName' => 'services',
'where' => 'title = '.$service_feature,
));

foreach ($servicesRecordsSF as $record) {
print "<ul>";
print "<li class=\"service_feature_popup_link cursor\" onclick=\"MM_openBrWindow('service-feature-popup.php?".$record['num']."','Features','toolbar=yes,location=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=400')\">".$record['title']."</li>";
print "</ul>";
}
$i++;
}
?>


Any help would be appreciated. Thank you in advance.

Re: [steve99] While Loop Loading Correlating Records Issue

By Jason - January 4, 2011

Hi,

I think the problem is not putting quotes around your $service_feature in your where clause. MySQL thinks you're trying to compare it to another column. Try this:

list($servicesRecordsSF, $servicesMetaDataSF) = getRecords(array(
'tableName' => 'services',
'where' => "title = '".$service_feature."'",
));


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/