<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Display related table fields for each listing on a LIST page</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Display-related-table-fields-for-each-listing-on-a-LIST-page-82827</link>
        <description></description>
        <pubDate>Wed, 20 May 2026 02:48:58 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Display-related-table-fields-for-each-listing-on-a-LIST-page-82827" rel="self" type="application/rss+xml" />

                <item>
          <title>Display related table fields for each listing on a LIST page</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2247313#post2247313</link>
          <description><![CDATA[<p>Dave, success!</p>
<p>Turns out I provided the incorrect field name for the r<span>adio field in the 'paintings' table. It should have been "galleries_num", not "gallery_showing".</span></p>
<pre class="language-markup"><code>&lt;?php $gallery = $numToGallery[$record['galleries_num']] ?? []; ?&gt;</code></pre>
<p>Many thanks for the code and the explanation! I'll likely be using this method quite often in the future.</p>
<p>~ Deborah</p>]]></description>
          <pubDate>Fri, 28 Jun 2024 10:02:28 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2247313#post2247313</guid>
        </item>
                <item>
          <title>Display related table fields for each listing on a LIST page</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2247312#post2247312</link>
          <description><![CDATA[<p>Hi Deborah, </p>
<p>Sure, and feel free to send in a 2nd level support request if you don't get it right away and I'll take a look:<br /><a href="https://www.interactivetools.com/support/request/" rel="nofollow">https://www.interactivetools.com/support/request/</a></p>
<p>When we can see the code it just takes a minute.</p>
<p>Good luck!</p>]]></description>
          <pubDate>Thu, 27 Jun 2024 16:11:20 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2247312#post2247312</guid>
        </item>
                <item>
          <title>Display related table fields for each listing on a LIST page</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2247311#post2247311</link>
          <description><![CDATA[<p>Dave, thank you for your code suggestion.</p>
<p>I didn't have success with my first implementation attempt, but will have a  fresh look in the AM (East Coast time here).</p>
<p>Your help is much appreciated, as always!<br />~ Deborah</p>]]></description>
          <pubDate>Thu, 27 Jun 2024 16:06:49 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2247311#post2247311</guid>
        </item>
                <item>
          <title>Display related table fields for each listing on a LIST page</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2247309#post2247309</link>
          <description><![CDATA[<p>Hi Deborah, </p>
<p>If you have under a hundred galleries, you could just load them all into memory and look them up by num like this: </p>
<pre class="language-php"><code>// load records from 'galleries'
[$galleriesRecords, $galleriesMetaData] = getRecords([
    'tableName'     =&gt; 'paintings',
    'loadUploads'   =&gt; true,
    'allowSearch'   =&gt; false,
    'loadCreatedBy' =&gt; false,
]);
$numToGallery = array_column($galleriesRecords, null, 'num');</code></pre>
<p>Then you can load and display them like this:</p>
<pre class="language-php"><code>&lt;?php foreach ($paintingsRecords as $record): ?&gt;
  &lt;?php $gallery = $numToGallery[$record['gallery_showing']] ?? []; ?&gt;

    &lt;?php if (!empty($gallery['website_url'])): ?&gt;
        Website: &lt;?php echo htmlencode($gallery['website_url']) ?&gt;
    &lt;?php else: ?&gt;
        (No website)
    &lt;?php endif ?&gt;</code></pre>
<p>Here's what's happening: </p>
<ul>
<li>We're assuming that paintings.gallery_showing contains the record number of the galley, e.g., gallery.num</li>
<li>We create an array of galleries indexed by their record num so we can look them up by gallery num</li>
<li>As we loop over the painting records, we try and set $galley to the gallery record from our $numToGallery array</li>
<li>If there's no gallery defined, or it's not found, the (PHP8) ?? code means "if the previous value wasn't set use the next one, and [] is an empty array</li>
<li>So $gallery is an array of gallery values or an empty array.</li>
<li>Then we just check if each value you want is defined and show it.</li>
</ul>
<p>Hope that helps!  Let me know if that works for you.</p>]]></description>
          <pubDate>Thu, 27 Jun 2024 15:28:08 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2247309#post2247309</guid>
        </item>
                <item>
          <title>Display related table fields for each listing on a LIST page</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2247308#post2247308</link>
          <description><![CDATA[<p>Hey, All.</p>
<p>At the risk of being overly insistent...</p>
<p>Someone out there in CMSB Land must have this solution in their toolkit? Any insights would be greatly appreciated!</p>
<p>Thanks!<br />~ Deborah</p>]]></description>
          <pubDate>Thu, 27 Jun 2024 14:24:02 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2247308#post2247308</guid>
        </item>
                <item>
          <title>Display related table fields for each listing on a LIST page</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2247298#post2247298</link>
          <description><![CDATA[<p>Hello, All.</p>
<p>I'm attempting to display data on a LIST page from a related table using a "List Options from Database" radio field.</p>
<p>No errors appear, but neither does the related 'website_url' field or other related fields.</p>
<p>Setup for the "gallery_showing" radio field in the 'paintings' table:<br /> Get Options from database (advanced)<br /> Section Tablename = galleries<br /> Option values = num<br /> Option labels = gallery_name</p>
<pre class="language-markup"><code>// Get list of paintings
  list($paintingsRecords, $paintingsMetaData) = getRecords(array(
    'tableName'   =&gt; 'paintings',
    'where' =&gt; ' category LIKE "%available%" ', 
    'loadUploads' =&gt; true,
    'allowSearch' =&gt; false,
    'loadCreatedBy' =&gt; false,
  ));
  
  // load records from 'galleries'
  list($galleriesRecords, $galleriesMetaData) = getRecords(array(
    'tableName'   =&gt; 'galleries',
    'loadUploads' =&gt; true,
    'allowSearch' =&gt; false,
    'loadCreatedBy' =&gt; false,
  ));

-------------

&lt;?php foreach ($paintingsRecords as $record): ?&gt;

 
 &lt;?php // load info from 'paintings' table
       foreach ($record['painting'] as $index =&gt; $upload): ?&gt;
         &lt;img src="&lt;?php echo htmlencode($upload['thumbUrlPath2']) ?&gt;"&gt;
      &lt;?php endforeach ?&gt; 
     
     
  &lt;?php // load record from 'galleries' table
      // that matches this painting's selection for "gallery_name"   
           list($galleriesRecords, $galleriesMetaData) = getRecords(array(
          'tableName'   =&gt; 'galleries',
          'where'       =&gt; "`num` = ".$record['num'],
          'allowSearch' =&gt; false,
          'limit'       =&gt; '1',
     ));
    ?&gt; 
    
  &lt;?php // display all 'galleries' table related fields
           if (!empty($galleriesRecord['website_url'])): ?&gt;
           Website: &lt;?php echo htmlencode($galleriesRecord['website_url']) ?&gt;
           &lt;?php else: ?&gt;
           (No website)
           &lt;?php endif ?&gt;
    
    [... do same for other related fields ...]
    

&lt;?php endforeach ?&gt;
</code></pre>
<p>The code below is mostly based on code from another project, but I can't determine the differences. Hope I'm at least headed in the right direction?</p>
<p>Thanks in advance for any insights!<br />~ Deborah</p>]]></description>
          <pubDate>Mon, 24 Jun 2024 12:00:25 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2247298#post2247298</guid>
        </item>
              </channel>
    </rss>
  