Show records from multi select menu

4 posts by 2 authors in: Forums > CMS Builder
Last Post: October 21, 2008   (RSS)

By Ryan - October 20, 2008

Hi, the following page is almost complete i just need to figure a way of filtering the results from one of the tables.

[url "http://traceybros.vbs4u.com/developments/display.php?Featherbed-Glade-1"]http://traceybros.vbs4u.com/developments/display.php?Featherbed-Glade-1[/#800080][/url]

As you can see the page lists estate agents at the bottom who are selling property in the particular development you are viewing. However the list is displaying all the records in the 'estate_agents' table not just the ones i have selected using a database multi-select list from the 'developments' table.

How can you get these records to filter correctly bearing in mind that each development will have multiple estate agents and each estate agent will be selling properties in multiple developments. I have attached the page and added some comments on the page to show you what im trying to do. Any help would be greatly appreciated.

Thanks
Attachments:

display_002.php 11K

Re: [ryan_dot] Show records from multi select menu

By Dave - October 20, 2008

Hi ryan_dot,

What's the name of the field in the 'developments' table that has the agents values in it? Can you print out the value of that field and post it. Try some code like this, except with the correct fieldname:

<xmp><?php print_r($developmentsRecords['agents']); ?></xmp>

The first step is determining what values we have. Then figuring out how to turn it into a where query.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Show records from multi select menu

By Ryan - October 21, 2008

Hi Dave, found a post on the forum where you answered this before, spent hours looking yesterday with no joy and it was near the first post i found today.

Thanks,

http://www.interactivetools.com/forum/forum.cgi?post=63527

This is the code i used

// get where
$recordNumbersArray = getListValues('developments', 'agents', $developmentsRecord['agents']);
$recordNumbersAsCSV = join(', ', $recordNumbersArray);
if (!$recordNumbersAsCSV) { $recordNumbersAsCSV = "0"; }

// prevent error from having empty string if no matches
// load all records
list($estate_agentsRecords, $estate_agentsMetaData) = getRecords(array(
'tableName' => 'estate_agents',
'allowSearch' => '0',
'where' => "num IN ($recordNumbersAsCSV)",

));