{"id":315,"date":"2025-03-13T10:45:30","date_gmt":"2025-03-13T10:45:30","guid":{"rendered":"https:\/\/documentation.iqonic.design\/graphina\/?p=315"},"modified":"2025-03-13T10:45:31","modified_gmt":"2025-03-13T10:45:31","slug":"using-sql-builder-to-fetch-dynamic-data-for-wordpress-charts","status":"publish","type":"post","link":"https:\/\/documentation.iqonic.design\/graphina\/using-sql-builder-to-fetch-dynamic-data-for-wordpress-charts\/","title":{"rendered":"Using SQL Builder to Fetch Dynamic Data for WordPress Charts"},"content":{"rendered":"<div class=\"nolwrap\">\n<h4 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h4>\n\n\n\n<p>In this guide, we&#8217;ll explore the fastest way to integrate <strong>dynamic charts<\/strong> in WordPress using <strong>SQL Builder<\/strong> with MySQL and PHP. Instead of manually updating data, you can leverage <strong>SQL queries<\/strong> to pull real-time information directly from your WordPress database.<\/p>\n\n\n\n<p>We\u2019ve previously discussed <strong>dynamic data<\/strong> and its sources\u2014now, it&#8217;s time to put that knowledge into action. This tutorial will transform a <strong>static chart<\/strong> into a <strong>fully dynamic<\/strong> one using SQL Builder.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How to Use SQL Builder for Dynamic Charts<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 1 \u2013 Select Your Chart<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open <strong>Graphina \u2013 WordPress Chart Plugin<\/strong>.<\/li>\n\n\n\n<li>Choose the chart type where you want to display data (e.g., <strong>Line Chart<\/strong>).<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1139\" height=\"573\" src=\"https:\/\/documentation.iqonic.design\/graphina\/wp-content\/uploads\/sites\/3\/2025\/03\/image-1.png\" alt=\"\" class=\"wp-image-316\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 2 \u2013 Switch from Manual to Dynamic Data<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Navigate to the <strong>chart data settings<\/strong>.<\/li>\n\n\n\n<li>Change the data source from <strong>\u201cManual\u201d<\/strong> to <strong>\u201cDynamic\u201d<\/strong>.<\/li>\n\n\n\n<li>At this stage, the chart might display <strong>\u201cNo Data Available\u201d<\/strong>\u2014this is expected because the data source hasn\u2019t been selected yet.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1296\" height=\"499\" src=\"https:\/\/documentation.iqonic.design\/graphina\/wp-content\/uploads\/sites\/3\/2025\/03\/image-2.png\" alt=\"\" class=\"wp-image-317\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 3 \u2013 Enable SQL Builder<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1296\" height=\"505\" src=\"https:\/\/documentation.iqonic.design\/graphina\/wp-content\/uploads\/sites\/3\/2025\/03\/image-3.png\" alt=\"\" class=\"wp-image-318\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the <strong>Dynamic Data Options<\/strong>, select <strong>\u201cSQL Builder\u201d<\/strong> as the data source.<\/li>\n\n\n\n<li>You will now see a <strong>text area<\/strong> where you can enter an SQL query.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1295\" height=\"504\" src=\"https:\/\/documentation.iqonic.design\/graphina\/wp-content\/uploads\/sites\/3\/2025\/03\/image-4.png\" alt=\"\" class=\"wp-image-319\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 4 \u2013 Selecting a Table<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on <strong>\u201cSelect Mode\u201d<\/strong>, which allows you to choose a table.<\/li>\n\n\n\n<li>A drop-down list of available <strong>WordPress database tables<\/strong> will appear.<\/li>\n\n\n\n<li>Select a table from the list\u2014the chart will instantly reflect the selected table&#8217;s data.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1304\" height=\"480\" src=\"https:\/\/documentation.iqonic.design\/graphina\/wp-content\/uploads\/sites\/3\/2025\/03\/image-5.png\" alt=\"\" class=\"wp-image-320\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1147\" height=\"597\" src=\"https:\/\/documentation.iqonic.design\/graphina\/wp-content\/uploads\/sites\/3\/2025\/03\/image-6.png\" alt=\"\" class=\"wp-image-321\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1145\" height=\"600\" src=\"https:\/\/documentation.iqonic.design\/graphina\/wp-content\/uploads\/sites\/3\/2025\/03\/image-7.png\" alt=\"\" class=\"wp-image-322\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 5 \u2013 Writing and Executing SQL Queries<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Write your SQL Query<\/strong> inside the text area. The query will execute automatically, updating the chart in real time.<\/li>\n\n\n\n<li>The <strong>column list<\/strong> from your SQL query result will be available for <strong>X-Axis and Y-Axis<\/strong> selection.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step 6 \u2013 Finalizing the Chart<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on <strong>\u201cExternal\u201d<\/strong> under the SQL Builder options.<\/li>\n\n\n\n<li>Choose a dataset from the dropdown (<strong>e.g., WordPress 2<\/strong>).<\/li>\n\n\n\n<li>Edit your <strong>SQL Raw Query<\/strong> and select the <strong>desired column<\/strong> for the Y-axis.<\/li>\n\n\n\n<li>The chart will now display live <strong>database-driven<\/strong> data.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Key Features &amp; Notes<\/strong><\/h3>\n\n\n\n<p>\u2705 <strong>Supports Any WordPress Database Table<\/strong> \u2013 Fetch data from any table in your WordPress database.<br>\u2705 <strong>Uppercase Column Names<\/strong> \u2013 Enable the setting for capitalized column names if needed.<br>\u2705 <strong>Offset &amp; Limit Control<\/strong> \u2013 Set to <code>NULL<\/code> if not required.<br>\u2705 <strong>Instant Data Execution<\/strong> \u2013 SQL queries automatically update the chart upon execution.<\/p>\n\n\n\n<p>By following these steps, you can seamlessly integrate <strong>dynamic charts<\/strong> in WordPress using <strong>SQL Builder<\/strong>, eliminating the need for manual data updates! \ud83d\ude80<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Introduction In this guide, we&#8217;ll explore the fastest way to integrate dynamic charts in WordPress using SQL Builder with MySQL and PHP. Instead of manually updating data, you can leverage SQL queries to pull real-time information directly from your WordPress database. We\u2019ve previously discussed dynamic data and its sources\u2014now, it&#8217;s time to put that knowledge [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"parent":235,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-graphina"],"featured_image_src":null,"author_info":{"display_name":"wordpressadminiq","author_link":"https:\/\/documentation.iqonic.design\/graphina\/author\/wordpressadminiq\/"},"children":[],"_links":{"self":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":1,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":323,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/315\/revisions\/323"}],"up":[{"embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/235"}],"wp:attachment":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}