title: How to use global variable in mysqli_query statement
body: <p>I'm trying to create a function to count different table rows in my MySQL database. I have the following script, but when executing it, it will generate an error saying that the variable <code>$con</code> is not set, but it is. So my question is how can I use "global" in this statement?</p>
  
  <pre><code>function countrows($rows){
  $sql = mysqli_query($con,"SELECT * FROM $rows");
  $num_rows = mysqli_num_rows($sql);
  echo $num_rows;
  }
  </code></pre>