• Resolved ace0930

    (@ace0930)


    Hi, I got a table called newdata and there is a column called name. I’m trying to get the value of name where the ID is 1 by the following code:

    <?PHP
    $my_plugin = 'C:\laragon\www\NewSite\wp-config.php';
    include_once($my_plugin);
    $table_name = $wpdb->prefix . 'newdata';
    ?>

    the result is array if $results = $wpdb->get_col($wpdb->prepare("SELECT name FROM $table_name WHERE id = 1")); and the result is 1 if $results = $wpdb->query($wpdb->prepare("SELECT name FROM $table_name WHERE id = 1"));.

    But the value is actually blue, anything I do wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cannot get data from table of WordPress MYSQL’ is closed to new replies.