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>"
    SEMrush

    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
    SEMrush
  2. jestep

    jestep Prominent Member Premium Member

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