I have this below SQL which looks at NextGen Gallery's wp_ngg_tags table, and do a count. Then it loops through all the rows to bring back the name value.
I couldn't get it to do what I wanted, but it does the "count" alright.
<?php
global $wpdb;
$sql = 'SELECT COUNT(*) FROM wp_ngg_tags ';
$count= $wpdb->get_var($sql);
echo $count;
echo "<hr>";
for ( $counter = 1; $counter <= $count; ) {
$row = 'SELECT name FROM wp_ngg_tags where id='.$counter;
$name= $wpdb->get_var($row);
echo $name;
$counter=$counter+1;
}
?>
Any help would be appreciated.