-
AuthorPosts
-
July 24, 2014 at 11:59 pm #295706
Using the page builder, is it possible to a table query using PHP in the Code Block? I have a table with products and want to use an Ajax form to query and display them on a page. I tried a code sample:
global $wpdb;
$wp_products = $wpdb->get_results(“SELECT * FROM catalog;”);
echo “<table>”;
foreach($catalog as $catalog){
echo "<tr>";
echo "<td>".$wp_products->ITEM."</td>";
echo "<td>".$wp_products->DESCRIPTION."</td>";
echo "<td>".$wp_products->COLOR."</td>";
echo "<td>".$wp_products->TYPE."</td>";
echo "</tr>";
}
echo "</table>";Is this possible? Any recommendations on how to implement this on a page? - I did try putting the <?php> tags, but no go.
-
This topic was modified 11 years, 3 months ago by
jlarmen.
July 25, 2014 at 1:34 am #295735Hi!
No, thats not possible out of the box. The code block element only runs HTML, CSS and JavaScript. There are some plugins that can help you with that however, take a look:
https://wordpress.org/plugins/insert-php/Regards,
JosueJuly 25, 2014 at 5:28 am #295786So are you saying not to use the Code block? Can I use the Insert PHP with the code block? Am I stuck using generic page elements and not the Avia layouts?
-
This reply was modified 11 years, 3 months ago by
jlarmen.
July 25, 2014 at 6:27 am #295791No, most Avia elements are able to run shortcodes (Insert PHP uses this), try using a Text Block if it doesn’t work with a Code Block.
Best regards,
JosueJuly 25, 2014 at 8:26 am #295816This reply has been marked as private.July 25, 2014 at 11:05 am #295866Hey!
Please update to Enfold 2.9.1. It should also support shortcodes in the “Code” elemement and then you should be able to use it with the insert_php shortcode like here: http://wamitag.com/Dev_2/?page_id=10
Best regards,
PeterJuly 25, 2014 at 5:11 pm #296043Please close this Dude, I think I’m going to use WooCommerce to manage the products.
-
This reply was modified 11 years, 3 months ago by
jlarmen.
-
This topic was modified 11 years, 3 months ago by
-
AuthorPosts
- The topic ‘PHP DB query in Code Block’ is closed to new replies.
