This topic is locked

loop duplicates row

6/30/2021 10:14:36 AM
PHPRunner General questions
Lance Spurgeon author

In the field custom section I am trying run a result where there are multiple values
The code is working but it duplicates the entries, what am I doing wrong?

$menu = DB::Query( "SELECT item_name, href FROM cms_menu where menu_id IN (".$data["associated_posts"].")" );
$value = '';
$value .= '<h2>Related Articles</h2>';
$value .='<ul>';
while( $record = $menu->fetchAssoc() ){
$value .='<li><a href="'.$record["href"].'" class="post-link">'.$record["item_name"].'</a></li>';
$value .='</ul>';

Related Articles
Getting Started
Icon Glossary

Related Articles
Getting Started
Icon Glossary

admin 6/30/2021

This is the way how it works if you have a multiple selection lookup wizard, 'View as' Custom will be applied for each individual value.

Instead of 'View as' Custom you can try Before Record Processed event.