I'm pulling information from the WordPress database. It's definitely pulling all the correct information and if I display the information with print_r( $res, true )
it shows what i require which is:
[term_id] => 8 [name] => Africa [slug] => africa [COUNT(a.id)] => 1
I need to echo the COUNT(a.id)
but I can't seem to manage this? My full code is here: http://pastie.org/4121409
I have managed to echo all the other information, just not the COUNT(a.id)
Thanks in advance!
When selecting, use column aliases, like this: COUNT(a.id) AS id_count
Then it will appear as the field name in result set, instead of COUNT(a.id)
and you will be able to access it by $rs->id_count
Also note that in your original code, line 22 will break the code. It should have been $counter = "COUNT(a.id)";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.