display multiple records
9 posts by 3 authors in: Forums > CMS Builder
Last Post: November 25, 2010 (RSS)
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
By Toledoh - November 25, 2010
Great looking site!
Is it the "'limit' => 1," causing the problem?
Tim (toledoh.com.au)
Re: [Toledoh] display multiple records
Re: [Dan Maitland] display multiple records
By Toledoh - November 25, 2010
Tim (toledoh.com.au)
Re: [Dan Maitland] display multiple records
By Jason - November 25, 2010
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: [Dan Maitland] display multiple records
By Jason - November 25, 2010
What are the names of the agent check boxes you're using?
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: [Dan Maitland] display multiple records
By Jason - November 25, 2010
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/