Complicated PHP Query Question

2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 4, 2014   (RSS)

By theclicklab - August 31, 2014

I have a bit of php code I need assistance with. I am trying to change the 

<?php if ($yachtsRecord['destinations']): ?>
<p><strong>Zone de navigation:</strong> 
<?php 
$values = getListValues('yachts','destinations',$yachtsRecord['destinations']); 
$labels = getListLabels('yachts','destinations',$yachtsRecord['destinations']); 
$valuesToLabels = array_combine($values, $labels); 
?>

This code pulls data from a table called "yachts". But I need to change the label in the above code to another field called "name_fr" which is in a table called "destinations". 

I have attached a screen grab of how this field is setup in the yachts table and also the page code if it helps. The code above starts on line 145.

Does that make sense? Any suggestions much appreciated.

Many Thanks!!

Attachments:

field-options.jpg 59K

yacht.php 22K

By claire - September 4, 2014

Hey there, sorry for the late reply. You'll probably have to use a separate query to get the name_fr label, like so:

list($destinationRecords, $destinationRecordsMeta = getRecords(array(
    'tableName' => 'destinations',
));

Then line 152 is changed as follows:

<?php $countD=0; ?><?php foreach ($destinationRecords as $destination): ?><?php echo ($countD==0)? "" : ", " ?><a href="/fr/destination.php/<?php echo str_replace(" ","-",strtolower($destination['name_fr']."-".$destination['num'])); ?>/"><?php echo htmlspecialchars($destination['name_fr']); ?></a><?php $countD++;?><?php endforeach ?>

Hopefully this should work.

--------------------

Claire Ryan
interactivetools.com

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