title: Check if array is empty
body: <p>The following code shows an array of records in the <code>$rows</code> array from the MySQL query. I have added also an <code>if</code> statement to check if <code>$rows</code> turns up empty, but it is not working.</p>
  
  <pre><code>$rows = array();
  
  $result1 = mysql_query("SELECT * FROM TestPhase where Pid&lt;10", $db) or die("cannot select");
  while($row = mysql_fetch_array($result1)) {
    $rows []= array(
      'id' =&gt; $row['id'],
      'parent' =&gt; $row['parent'],
      'name' =&gt; $row['name'],
    );
  
  }
  
  
  if($rows == ""){
      echo "No Data";
  
      }
  </code></pre>
  
  <p>This <code>if</code> statement is not working. How do I check if the array returns empty and echo "No Data". </p>
  
  <p>How would I check to see if the array is empty in javascript? I have placed the <code>$rows</code> array in a <code>var treeData</code>.</p>
  
  <pre><code>if (treeData) is empty{
  $("button").hide();
       }
  </code></pre>
  
  <p>How do I check if <code>treeData</code> is empty to hide the button.</p>