I have a function that gets the number of unpublished records from a table (which works fine). However now I want to get the total number of unpublished occurances in multiple tables. I figure I can do a foreach loop using the $tables = array(‘projects’, ‘testimonials’) .etc. then add together their respective results to get total number and return that? However I am not sure how to do this, this kindof loop is a bit outside my abilities.
function publishCount($table) {
$sql = mysql_query("SELECT COUNT(*) AS nb FROM ".$table." WHERE published='0' OR published=''") or die(mysql_error());
$result = mysql_result($sql, 0);
if (!$result == 0) { echo 'Awaiting to be published <span class="badge badge-important">'.$result.'</span>'; }
else { echo 'Awaiting to be published <span class="badge badge-inverse">'.$result.'</span>'; }
}
You should edit your function this way:
So you can then do a loop through your
$tableslist: