Hello.
I’m trying to build an embed code that will query a database and then show matched results. This will end up being for geo-location.
Below is a simplified snippit of my code.
{exp:query sql="SELECT entry_id FROM exp_matrix_data WHERE col_id_32 = 'NJ' LIMIT 1"}
{if no_results}
Sorry, there is no rep in your area. Please call the main office for help.
{/if}
{exp:channel:entries channel="rep_info" entry="{entry_id}" limit="1"}
{!-- These will not show up on category or entry pages --}
{title}, {matrix_field}{matrix_field_column}{/matrix_field}
{/exp:channel:entries}
{/exp:query}I’m able to get the “no_results” to display, but I cannot get matched results to show on any pages deeper then than the second segment. For example, the code will work on url.com/template_group, but not on url.com/template_group/category/category_title or url.com/template_group/template/entry_id.
Is there anyway that I can fix this? The root of the situation is that I need to be able to display all content for any matched entry_id that I get from my query, including data inside the matrix form filed.
Running EE2.4
Edit:
This wasn’t really working. I just happened to pull the most recent entry that matched my test condition, and no entry when there wasn’t any success. When I add more that doesn’t meet the conditions, it show’s the most recently added picture.
Any ideas on how I can use query string with matrix to get the data I want to display? Also, I fixed the entry=”{entry_id}”