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_countThen 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_countAlso note that in your original code, line 22 will break the code. It should have been
$counter = "COUNT(a.id)";