如何在函数中传递变量:table和id

database

    <?php 

$host = 'localhost';
$user = 'root';
$password = '';
$database = 'test';

$link = new mysqli($host, $user, $password, $database);

/* check connection */
if ($link->connect_errno) {
    printf("Connect failed: %s
", $mysqli->connect_error);
    exit();
}

?>

View List function

    function viewList($table, $id){
  global $link;
  $table = $table;
  $id = $id;

  $query = 'SELECT * FROM '. $table .' ORDER BY '. $id .' DESC';
  $statement = mysqli_query($link, $query) or die ('A problem with database');
  // $result = $statement->get_result();
  // $statement->store_result();
  // $check = $result->num_rows;
  $check = mysqli_num_rows($statement);

 // $result = mysqli_query($mysqli,$query) or die('a problem with database');
 // $check = mysqli_num_rows($result);
   if($check > 0){
        echo '<div class="table-responsive">';
        echo '<table class="table table-condensed table-striped table-bordered table-hover no-margin">';
        echo '<thead>';
        echo '<tr>';
        echo '<th style="width:40%">Name</th>';
        echo '<th style="width:20%" class="hidden-phone">Address</th>';
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';

        while ($row = mysqli_fetch_array($statement)):
          echo '<tr>';
                echo '<td>'. $row['employee_name'] . '</td>';
                echo '<td>'. $row['employee_address'] . '</td>';
                echo '</tr>';
       endwhile;

       echo '</tbody>';
       echo '</table>';
       echo '</div>';
       $link->close();
    }
   else{
    echo '<div class="alert alert-warning">No records found</div>';
   }
}

in view record page

     <?php
           include 'database.php';
           include "functions/crud.php";
           viewList("employees", "employee_id");           
   ?>

The problem is that the result is not displayed on page -- blank. No error message appears. "No records found" is printed. in database, there are 3 records.

Is it not possible to just pass variables in the viewList() function? Wanted the ease of add function to some pages with different tables and id name.