Tagged: , , ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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 10 years, 4 months ago by jlarmen.
    #295735

    Hi!

    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,
    Josue

    #295786

    So 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 10 years, 4 months ago by jlarmen.
    #295791

    No, 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,
    Josue

    #295816
    This reply has been marked as private.
    #295866

    Hey!

    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,
    Peter

    #296043

    Please close this Dude, I think I’m going to use WooCommerce to manage the products.

    • This reply was modified 10 years, 4 months ago by jlarmen.
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘PHP DB query in Code Block’ is closed to new replies.