PHP If statement problem
<p>For the code below, I am trying to use the IF statement </p>

<blockquote>
  <p>if(mysql_num_rows($resA)>0)</p>
</blockquote>

<p>to avoid running the foreach loop if $entry is not in the "site" column in any table in my database.  However, if $entry does not exist in the "site" column in any table in my database, I get the error message "Warning: Invalid argument supplied for foreach()".  Any idea why it is doing that?</p>

<p>Thanks in advance,</p>

<p>John</p>

<pre><code>$result = mysql_query("SHOW TABLES FROM feather") 
or die(mysql_error()); 

while(list($table)= mysql_fetch_row($result))
{
  $sqlA = "SELECT COUNT(*) FROM `$table` WHERE `site` LIKE '$entry'";

  $resA = mysql_query($sqlA) or die("$sqlA:".mysql_error());
  list($isThere) = mysql_fetch_row($resA);
  $isThere = intval($isThere);
  if ($isThere)
  {
     $table_list[] = $table;
  }

}

if(mysql_num_rows($resA)&gt;0){
foreach ($table_list as $table) { 
    $sql = "SELECT votes_up FROM `$table` WHERE `site` LIKE '$entry'"; 
    $sql1 = mysql_query($sql) or die("$sql:".mysql_error());
   while ($row = mysql_fetch_assoc($sql1)) {
       $votes[$table] = $row['votes_up'];
       $sum += $row['votes_up'];
   } 

}
}
else{
print "";
}
</code></pre>
