Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9282227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:19:14+00:00 2026-06-18T18:19:14+00:00

function get_entry_count($pagename) { global $wpdb; $count = $wpdb->get_results(SELECT COUNT( * ) FROM wp_fpc_rg_lead_detail WHERE

  • 0
function get_entry_count($pagename) {
    global $wpdb;
    $count = $wpdb->get_results("SELECT COUNT( * ) FROM wp_fpc_rg_lead_detail WHERE form_id =12 AND field_number =5 AND value =  '$pagename'" );
    return $count[0]->count;
    }

    $numofpeople = get_entry_count($post->post_title);
    echo "$numofpeople people filled out the form";

I’m trying to run the query above and output the number of records that match. If I add:

print_r($count);

above the return command, I get this:

Array ( [0] => stdClass Object ( [COUNT( * )] => 7 ) )

There ARE 7 records; and the returned value SHOULD BE 7.

But, the returned value ( $count[0]->count; ) seems to be null.. I’m sure it’s something stupid, but I just can’t get it to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:19:15+00:00Added an answer on June 18, 2026 at 6:19 pm

    Try giving your COUNT(*) an alias in the query. Then you should be able to reference the alias as a property of the object. In the example below I have used lead_detail_count but feel free to change it to whatever you want.

    function get_entry_count($pagename) {
        global $wpdb;
        $count = $wpdb->get_results("SELECT COUNT( * ) as lead_detail_count FROM wp_fpc_rg_lead_detail WHERE form_id =12 AND field_number =5 AND value =  '$pagename'" );
        return $count[0]->lead_detail_count;
    }
    

    get_results can also take a 2nd parameter that will change the return value and may be worth taking a look at. The link to the codex is below.
    http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$count = 5; function get_count() { static $count = 0; return $count++; } echo
I've a php function to get some data from mysql database: function get_persons() {
function get_arr($arr) { unset($arr[0]); } $arr1 = array(1,2); $arr2 = array(1,2); get_arr(&$arr1); get_arr($arr2); echo
I get error: ORA-06575: Package or function GET_CONC_NAMES is in an invalid state When
Can anyone describe the following php function: function get_setting_value($settings_array, $setting_name, $default_value = ) {
Given this function: > function Get-ArrayOfArrays() { (1,2),(3,4) | % { $_ } }
GET_DATA() GET_DATA() contains this: var xhr; ... function get_data( phrase ) { xhr =
I'm trying to write a calendar function like this function get_date($month, $year, $week, $day,
Suppose I have a conditional statement without brackets in a function: function get_user_id() {
I use the following javascript function, function get_check_value(formId,checkboxId,TxtboxId) { alert(formId); var c_value = ;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.