Wordpress does not bring the username Sql statement

0

I am modifying a wordpress plugin that brings me a series of fields from my table ..

$result = $wpdb->get_results(
    "SELECT * FROM '{$wpdb->prefix}statistics_visitor' ORDER BY '{$wpdb->prefix}statistics_visitor'.'ID' DESC  LIMIT 0, {$count}"
);

The problem is that I need to sort them in descending order, but if I order in that way, I no longer bring my user_name field that I add. But when the query is this way it works well ..

$result = $wpdb->get_results(
        "SELECT * FROM '{$wpdb->prefix}statistics_visitor' ORDER BY '{$wpdb->prefix}statistics_visitor'.'ID' LIMIT 0, {$count}"
    );'

This is the rest of the code, where it goes through the result of the query and then shows it

echo "<div class='log-latest'>";

$dash_icon = wp_statistics_icons( 'dashicons-visibility', 'visibility' );

foreach ( $result as $items ) {
    if ( substr( $items->ip, 0, 6 ) == '#hash#' ) {
        $ip_string  = __( '#hash#', 'wp-statistics' );
        $map_string = "";

        $user_name = __( '#hash#', 'wp-statistics' );

    } else {
        $ip_string = "<a href='admin.php?page=" .
                     WP_Statistics::$page['visitors'] .
                     "&type=last-all-visitor&ip={$items->ip}'>{$dash_icon}{$items->ip}</a>";
        $map_string
                   = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" .
                     __( 'Map', 'wp-statistics' ) .
                     "'>" .
                     wp_statistics_icons( 'dashicons-location-alt', 'map' ) .
                     "</a>";

        $user_name = "<b>Usuario: {$items->user_name}</b><br>"; 

    }

    echo "<div class='log-item'>";
    echo "<div class='log-referred'>{$user_name}</div>";
    echo "<div class='log-referred'>{$ip_string}</div>";
    echo "<div class='log-ip'>" . date( get_option( 'date_format' ), strtotime( $items->last_counter ) ) . "</div>";
    echo "<div class='clear'></div>";
    echo "<div class='log-url'>";
    echo $map_string;
    
asked by Hernan Chaparro 01.09.2018 в 20:42
source

0 answers