<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>If or where statement from another table</title>
        <link>https://interactivetools.com/forum/forum-posts.php?If-or-where-statement-from-another-table-80556</link>
        <description></description>
        <pubDate>Tue, 12 May 2026 01:58:57 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;If-or-where-statement-from-another-table-80556" rel="self" type="application/rss+xml" />

                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238928#post2238928</link>
          <description><![CDATA[<p>Thanks Gary, your suggestion did help enormously!</p>
<p>That date field ended up enlarging the hero/banner photo to about 600%.  Then I placed the code in a different location and it listed all of the course dates. Really weird. Nothing seems to work, but I can do a manual workaround (ie, delete the old fields manually).</p>
<p>Thank you again for your concern and time resolving this for me.  Priceless :)!</p>
<p>Cheers</p>
<p>Carole</p>

]]></description>
          <pubDate>Mon, 23 May 2016 04:03:10 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238928#post2238928</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238927#post2238927</link>
          <description><![CDATA[<p>Copy/paste can be dangerous. Sorry about that. I wonder why the date filter wasn't working. Hmmm. </p>

<p>Oh well as long as as you have something that works for you </p>]]></description>
          <pubDate>Mon, 23 May 2016 03:07:07 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238927#post2238927</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238926#post2238926</link>
          <description><![CDATA[<p>Hi Gary</p>

<p>Thanks for providing some further insight.  I finally got the code to work using:</p>
<p>// load records from 'calendar'<br />$whereValue = "title='{$coursesRecord['title']}'";</p>
<p>list($calendarRecords, $calendarMetaData) = getRecords(array(</p>
<p>'tableName' =&gt; 'calendar',<br /> 'where' =&gt; $where<span style="color:#ff0000;">Value,</span> <br /> 'loadUploads' =&gt; true,<br /> 'allowSearch' =&gt; false,<br /> ));</p>

<p>The date / today field code doesn't work as it just lists everything, so I'll do this part manually.</p>
<p>Thanks again for your help.</p>
<p>Regards</p>
<p>Carole</p>]]></description>
          <pubDate>Sun, 22 May 2016 20:23:17 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238926#post2238926</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238912#post2238912</link>
          <description><![CDATA[<p>I was looking for the actual schema files, not the HTML files, but...</p>
<p>It looks like your course in CALENDAR LIST is the field 'title' which is probably an string value, not a number, so you'd need to do something with 'title' in order to get the course info.</p>
<p>Possibly, your where clause could have (sometimes, to make things a bit more readable, I'll create the "wherevalue" variable separately BEFORE the getRecords statement):</p>
<p><code>$whereValue = "title='{$courseRecord['title']}'";</code></p>
<p>Note: I like to use the bracket notation - I find it a bit more readable.  This is equivalent to:</p>
<p><code>$whereValue = "title='" . $courseRecord['title'] . "'";</code></p>
<p>Then inside the getRecords array...</p>
<p><code>'where' =&gt; $whereValue,</code></p>
<p>So, my question is in looking at your code below, is there any difference between</p>
<p><code>Course (value): &lt;?php echo $record['title'] ?&gt;&lt;br/&gt;<br /> Course (label): &lt;?php echo $record['title:label'] ?&gt;&lt;br/&gt;</code></p>
<p>or are they displaying the same value?</p>
<p><strong>If they are different values, your "where" clause needs to reference whatever is displayed by $record['title'] from the $courseRecord array.</strong></p>
<p>If you are getting 500 errors, it means you have an error in your syntax and your server can't go on.</p>
<p>Since you are also checking against the date, you need to have a compound where clause.  In your existing code, you show:</p>
<p><code>list($calendarRecords, $calendarMetaData) = getRecords(array(<br /> 'tableName' =&gt; 'calendar',<br /> 'where' =&gt; "'date' &gt; '$today'", <br /> 'loadUploads' =&gt; true,<br /> 'allowSearch' =&gt; false,<br /> ));</code></p>
<p>by adding "AND" to the where clause with the title, you can filter on title as well.</p>
<p>Assuming you get $today by some means such as:</p>
<p>$today = date("Y-m-d H:i:s");</p>
<p>You could add the title clause to the where statement</p>
<p><code>$filterTitle = "`title`='" . $courseRecord['title'] . "'";<br />$today = date("Y-m-d H:i:s");<br />$whereValue = "`date` &gt; '$today' <strong>AND</strong> $filterTitle;<br /><br />list($calendarRecords, $calendarMetaData) = getRecords(array(<br /> 'tableName' =&gt; 'calendar',<br /> 'where' =&gt; $whereClause, <br /> 'loadUploads' =&gt; true,<br /> 'allowSearch' =&gt; false,<br /> ));<br /></code></p>
<p>Again, keep in mind this is speculation without seeing the actual schema. </p>]]></description>
          <pubDate>Fri, 20 May 2016 05:00:22 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238912#post2238912</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238910#post2238910</link>
          <description><![CDATA[<p>Hi Gary</p>
<p>The tables are set up in 2 different sections.  I hope this is the schema that is required?</p>
<p><strong>1.  COURSE DETAIL - it's on this page where I would like to list the dates</strong></p>
<p>&lt;h1&gt;Courses - Detail Page Viewer&lt;/h1&gt;<br /> Record Number: &lt;?php echo htmlencode($coursesRecord['num']) ?&gt;&lt;br/&gt;<br /> Course Name: &lt;?php echo htmlencode($coursesRecord['title']) ?&gt;&lt;br/&gt;<br /> Duration: &lt;?php echo htmlencode($coursesRecord['duration']) ?&gt;&lt;br/&gt;<br /> Location: &lt;?php echo htmlencode($coursesRecord['location']) ?&gt;&lt;br/&gt;<br /> Cost: &lt;?php echo htmlencode($coursesRecord['cost']) ?&gt;&lt;br/&gt;<br /> _link : &lt;a href="&lt;?php echo $coursesRecord['_link'] ?&gt;"&gt;&lt;?php echo $coursesRecord['_link'] ?&gt;&lt;/a&gt;&lt;br/&gt;</p>

<p><strong>2.  CALENDAR LIST - this table has the dates for all of the courses.  <span style="color:#ff0000;">The <span style="color:#0000ff;">Course value</span> below is a drop down pulled from <span style="color:#0000ff;">Courses</span> table above, using the <span style="color:#0000ff;">title</span> as the idenfier</span></strong></p>
<p>&lt;?php foreach ($calendarRecords as $record): ?&gt;<br /> Record Number: &lt;?php echo htmlencode($record['num']) ?&gt;&lt;br/&gt;<br /> Course (value): &lt;?php echo $record['title'] ?&gt;&lt;br/&gt;<br /> Course (label): &lt;?php echo $record['title:label'] ?&gt;&lt;br/&gt;<br /> Date: &lt;?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?&gt;&lt;br/&gt;&lt;!-- For date formatting codes see: <a href="http://www.php.net/date" rel="nofollow">http://www.php.net/date</a> --&gt;<br /> _link : &lt;a href="&lt;?php echo $record['_link'] ?&gt;"&gt;&lt;?php echo $record['_link'] ?&gt;&lt;/a&gt;&lt;br/&gt;<br /> &lt;hr/&gt;<br /> &lt;?php endforeach ?&gt;</p>
<p>&lt;?php if (!$calendarRecords): ?&gt;<br /> No records were found!&lt;br/&gt;&lt;br/&gt;<br /> &lt;?php endif ?&gt;</p>

<p>Thanks so much.</p>
<p>Carole</p>]]></description>
          <pubDate>Thu, 19 May 2016 21:19:48 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238910#post2238910</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238909#post2238909</link>
          <description><![CDATA[<p>Without knowing the exact setup of your tables, it's hard to say, but I use this type of thing all the time, so I'm guessing I just don't know how your tables are setup.</p>
<p>Sorry I didn't understand your environment correctly.  If you share the schema files in your post, it may assist in giving you an answer that will work.</p>
]]></description>
          <pubDate>Thu, 19 May 2016 20:57:04 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238909#post2238909</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238908#post2238908</link>
          <description><![CDATA[<p>Thanks, but that doesn't work.  It's giving me a 500 Server Error if I put any variation of that code in the line.</p>]]></description>
          <pubDate>Thu, 19 May 2016 20:39:47 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238908#post2238908</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238899#post2238899</link>
          <description><![CDATA[<p>You probably have, in your calendar table, a field that cross-references the course table.  For example, maybe you have a "coursenum" field that uses the "num" from the course table as it's value.</p>
<p>Assuming you have your current course record in an array called $courseRecord, and assuming I understand your question properly, you can add where =&gt; "coursenum={$courseRecord['num']}" to your getRecords command.</p>
<p>Also, regarding your dates, you can add publishDate and removeDate fields to your section and then the getRecords command will not pull records that haven't been published yet or records that have expired (past their remove date) so you don't have manually expire them.  However, you can also use the way you are doing it.  Either way works fine.</p>]]></description>
          <pubDate>Thu, 19 May 2016 05:07:49 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238899#post2238899</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238892#post2238892</link>
          <description><![CDATA[<p>Hi Damon</p>
<p>I have another list called Calendar, which just lists all of the courses and their specific date.  Course A might have 3 different dates, Course B 6 different dates, etc.  And new dates will be added as the calendar year progresses.  What I want to do is list these dates on the Course A or Course B, etc detailed pages, and have the flexibility to order by first forthcoming date, next sequential date.  An example of a course details (eg. Course A) is <a href="http://cp124.ezyreg.com/~coco6119/codelime_courses2.php?1" rel="nofollow">http://cp124.ezyreg.com/~coco6119/codelime_courses2.php?1</a> </p>
<p>// load records from 'calendar'<br /> list($calendarRecords, $calendarMetaData) = getRecords(array(<br /> 'tableName' =&gt; 'calendar',<br /> 'loadUploads' =&gt; true,<br /> 'allowSearch' =&gt; false,<br /> ));</p>
<p>and the two fields are </p>
<p>Record Number: &lt;?php echo htmlencode($record['num']) ?&gt;&lt;br/&gt;<br /> Course (value): &lt;?php echo $record['title'] ?&gt;&lt;br/&gt;<br /> Course (label): &lt;?php echo $record['title:label'] ?&gt;&lt;br/&gt;<br /> Date: &lt;?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?&gt;&lt;br/&gt;&lt;!-- For date formatting codes see: <a href="http://www.php.net/date" rel="nofollow">http://www.php.net/date</a> --&gt;</p>
<p>It's sort of a fix in the absence of a calendar type plugin.  The calendar they have at <a href="https://www.phpjabbers.com/event-booking-calendar/" rel="nofollow">https://www.phpjabbers.com/event-booking-calendar/</a> is a great piece of calendar software, but it doesn't plug in with CMS Builder and I can't extract just a string of single course dates for a specific course.  So this is the compromise, combined with www.machform.com as the form/payment editor.</p>
<p>Any help you could provide with the where/if statement would be wonderful.</p>
<p>Thanks in advance.</p>
<p>Carole</p>]]></description>
          <pubDate>Wed, 18 May 2016 16:16:29 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238892#post2238892</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238888#post2238888</link>
          <description><![CDATA[<p>Hi,</p>
<p>From your code example so far, I can see the fields in the Calendar section editor. Is the other section editor just for the course names?</p>
<p>What is the end result you are after? The course dates grouped under the course name?</p>
<p>Let me know and then I can help put together some code examples.</p>
<p>Thanks!</p>]]></description>
          <pubDate>Wed, 18 May 2016 14:00:30 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238888#post2238888</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238878#post2238878</link>
          <description><![CDATA[<p>Sorted out the date issue, but not the other part...</p>
<p>// load records from 'calendar' that have a date greater than 1 second before midnight today.<br /> list($calendarRecords, $calendarMetaData) = getRecords(array(<br /> 'tableName' =&gt; 'calendar',<br /> 'where' =&gt; "'date' &gt; '$today'", <br /> 'loadUploads' =&gt; true,<br /> 'allowSearch' =&gt; false,<br /> ));</p>]]></description>
          <pubDate>Sun, 15 May 2016 16:25:36 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238878#post2238878</guid>
        </item>
                <item>
          <title>If or where statement from another table</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2238877#post2238877</link>
          <description><![CDATA[<p>I've searched the forum but can't seem to find an answer...</p>
<p>I have a list of courses, where the title field is the name of the course.  </p>
<p>     Course Name: &lt;?php echo htmlencode($coursesRecord['title']) ?&gt;&lt;br/&gt;</p>

<p>Each course has one or multiple course dates, so I've created a separate section called calendar, so I can sort by date, and also hide one if that date has expired (unless there's an easier, automatic way to do that?).  I've used the drop down list to select the course name to (hopefully) somehow link the two.  Now I am stuck.</p>
<p>&lt;?php foreach ($calendarRecords as $record): ?&gt;<br /> Record Number: &lt;?php echo htmlencode($record['num']) ?&gt;&lt;br/&gt;<br /> Course (value): &lt;?php echo $record['title'] ?&gt;&lt;br/&gt;<br /> Course (label): &lt;?php echo $record['title:label'] ?&gt;&lt;br/&gt;<br /> Date: &lt;?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?&gt;&lt;br/&gt;&lt;!-- For date formatting codes see: <a href="http://www.php.net/date" rel="nofollow">http://www.php.net/date</a> --&gt;<br /> _link : &lt;a href="&lt;?php echo $record['_link'] ?&gt;"&gt;&lt;?php echo $record['_link'] ?&gt;&lt;/a&gt;&lt;br/&gt;<br /> &lt;hr/&gt;<br /> &lt;?php endforeach ?&gt;</p>

<p>If for example, it's Course ABC showing on the page, how do I get the respective course dates to appear from the calendar?  I get that it has to do with the record number (which they share in common), but am stuck on whether it's a IF or WHERE or something else?</p>
<p>Any suggestions would be gratefully received.</p>
<p>Thanks in advance.</p>]]></description>
          <pubDate>Sun, 15 May 2016 16:19:08 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2238877#post2238877</guid>
        </item>
              </channel>
    </rss>
  