display multiple records

9 posts by 3 authors in: Forums > CMS Builder
Last Post: November 25, 2010   (RSS)

On this page I have leasing contacts in the right column.

http://173.236.177.72/suite.php?510-514-3

These agents are being pulled from the agent section which are check boxes in the suite section. Even if I select both agents only the first one shows up. This is the code that I have.

Code located at the top of the page:
list($agentsRecords, $agentsMetaData) = getRecords(array(
'tableName' => 'agents',
'where' => mysql_escapef('num = ?', $suitesRecord['agent']),
'limit' => 1,
));
$agentsRecord = $agentsRecords[0];
?>


Code in the page:

<?php foreach ($agentsRecords as $record): ?>
<?php echo $record['name'] ?>
<br />
T: <?php echo $record['phone'] ?> | F: <?php echo $record['fax'] ?> | E: <a href="mailto:<?php echo $record['email'] ?>"><?php echo $record['email'] ?></a>
<?php endforeach ?>

It is working to a degree where it is displaying at least one of the two agents that are selected but we need it to display all the agents that are selected. I'm sure that I am missing something small.

Re: [Dan Maitland] display multiple records

Hi Dan.

Great looking site!

Is it the "'limit' => 1," causing the problem?
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] display multiple records

That what I thought at first butevenafter changing it or even removing it it still won't display more than one agent at a time. I think it has something to do with an "array" but I'm not really sure.

Re: [Dan Maitland] display multiple records

Didn't think it would be that simple :)
Cheers,

Tim (toledoh.com.au)

Re: [Dan Maitland] display multiple records

By Jason - November 25, 2010

Hi Dan,

What type of field is $suiteRecord['agent']? Is it a multi-select checkbox field?

If it is, it's storing multiple agent numbers as a string separated by tab characters (\t). You can break it up and use it in your code like this:


$agentNums = str_replace("\t",",",trim($suiteRecord['agent'],"\t"));
if(!$agentNums){$agentNums = 0;}

list($agentsRecords, $agentsMetaData) = getRecords(array(
'tableName' => 'agents',
'allowSearch' => false,
'where' => "num IN (".mysql_escape($agentNums).")",
));


You would need to remove the limit=1 either way you'd only ever return one record anyway.

Give this a try and let me know if you run into any other problems.

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/

Re: [Jason] display multiple records

They are check boxes.

Re: [Jason] display multiple records

agent

Re: [Dan Maitland] display multiple records

By Jason - November 25, 2010

Hi,

Please send in a [url http://www.interactivetools.com/support/]2nd Level Support Request[/url] so I can go in and take a closer look at what's happening.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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