Related Entries

5 posts by 2 authors in: Forums > CMS Builder
Last Post: June 30, 2011   (RSS)

By Kenny - June 28, 2011

Hi all -

I am having a problem getting records from one table to show up with records from another.

Here's the idea...

I have a section called "models". This section was built to show the different models of building available.

Each model can have a multitude of floor plans. I have created another section called "floor plans" and tie the floor plans to the models with a drop down option (get options from a database).

So, if I have a model called Sandy Lake, I can now make as many floor plans as I want for Sandy Lake.



Now, the part I am failing at the moment:

How do I get all of the floor plans for Sandy Lake to show up on the model page for Sandy Lake?


list($modelsRecords, $modelsMetaData) = getRecords(array(
'tableName' => 'models',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$modelsRecord = @$modelsRecords[0]; // get first record


list($floor_plansRecords, $floor_plansMetaData) = getRecords(array(
'tableName' => 'floor_plans',
));


Thanks in advance...

Kenny

Re: [Kenny] Related Entries

By robin - June 29, 2011

Hey Kenny,

You'll need to match the num of the current model to the drop down of the floor plan. I've inserted an example below, you might need to change the name of the drop down - I've assumed it's called "model". This is also assuming you're using num for the drop down list option values.

list($floor_plansRecords, $floor_plansMetaData) = getRecords(array(
'tableName' => 'floor_plans',
'where' => "model='" . $modelsRecord['num'] . "'"
));


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [Kenny] Related Entries

By robin - June 30, 2011

Hey Kenny,

The getRecords code looks good to me.

Have you tried a test to see if it's not displaying cause of another reason further down in the code? Your display code has an 'if condition' in it that might be stopping output.

We can see if getRecords actually pulled anything by adding this line just below:
list($floor_plans_ulcRecords, $floor_plans_ulcMetaData) = getRecords(array(
'tableName' => 'floor_plans_ulc',
'where' => "series='" . $models_ulcRecord['num'] . "'"
));
showme($floor_plans_ulcRecords);


Hope that helps diagnose the problem,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Related Entries

By Kenny - June 30, 2011

Thanks - that was the problem. All is well now!

Kenny