1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to get the answer from a count() mysql

Discussion in 'MySQL' started by tommytx, Dec 24, 2017.

  1. #1
    $results = $wpdb->get_results('SELECT COUNT(*) AS "total" FROM wp_realty_listingsimages');

    echo $total;
    echo total;

    print "<pre>";
    print_r($results);
    print "</pre>"


    total
    Array
    (
    [0] => stdClass Object
    (
    [total] => 16876
    )

    )

    i want my answer to be like = 234 not all the other crap

    Like this
    My total for this table is $total. and it will print
    My total for this table is 234.
    do not want to see all that array stuff printed..
     
    tommytx, Dec 24, 2017 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    echo $results[0]->total;
     
    jestep, Dec 28, 2017 IP