Skip to main content
1 of 3
CodeX
  • 1.1k
  • 2
  • 13
  • 19

Select 4 different named columns across 4 tables and return the count of all

Ive been trying this for days, i want to count the amount of inactiveItems() from 4 tables, all help appreciated.

The database

Tables

  • wcx_articles
  • wcx_videos
  • wcx_apps
  • wcx_links

The corresponding _active column for each table

  • article_active
  • video_active
  • app_active
  • link_active

_active is a switch 1 or 0

This is my current function - it returns 0

 public function inactiveItems() {
        
$query = 
"SELECT * FROM wcx_articles,wcx_videos,wcx_apps,wcx_links 
WHERE wcx_articles.article_active='0' AND wcx_videos.video_active='0' 
AND wcx_apps.app_active='0' AND wcx_links.link_active='0'";

 if( $this->num_rows( $query ) > 0 ) {  
     $count = $this->num_rows($query);
     return $count;
     }      
 }

 public function num_rows( $query ) {
    $query = $this->link->query( $query );
    if( mysqli_error( $this->link ) ) {
        $this->log_db_errors( mysqli_error( $this->link ), $query, 'Fatal' );
        return mysqli_error( $this->link );
    }
    else {
        return mysqli_num_rows( $query );
    }
    mysqli_free_result( $query );
}
CodeX
  • 1.1k
  • 2
  • 13
  • 19