• I am new to WP but think its great and certainly consuming. I have cracked most of where I want to be and now hit a wall. I am trying to call data from a table whether it be the same as the WPDB or externally. I have read the instructions and find myself cornered.
    Q1 Can I put php code directly into a page created for the website e.g. page 32 when called? If so why is it not executing properly merely displaying part of the text e.g. It misses the first <php
    opening tag then displays (ignore the ” ” its the exact text between

    global $wpdb;
    $myrows = $wpdb->get_results( “SELECT id, name FROM myTable” );
    ?>

    Q2 If I can access the table direct from the page what am I doing wrong?
    Q3 Can someone point me correctly as to how to make $WPDB global? I dont understand fully classes but have some understanding of php, mysql and can build the outines outside of wordpress – but don’t want to as I am hooked with it now ?? Any help would be appreciated
    Thanks in advance.
    Steve

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can’t place PHP code in a page (or a post) unless you’re using one of the PHP execution plugins. The simplest option is to create a custom page template, add your custom code to that template and assign the new template to the appropriate page(s).

    Thread Starter sh864

    (@sh864)

    Thank you I will give it a go I thought there was something of a hurdle like that. Regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WPDB and Word Press Pages’ is closed to new replies.