PHP如何查询mysql数据库中有无指定表

对不同数据库某个表可能有也可能无,处理前需查询下,使用
mysql_query("select * from mytable")
如遇mytable不存在,程序走不下去了,而且也不报错(mysql_error())
希望表不存在时能根据查询结果进入其他分支,php该如何写?
谢谢

  $db = new mysqli('localhost','root','wasdwasd','bookdb');
  $tableN = 'user';
  $sqlHT = "show tables like '$tableN'";
  $haveT = mysqli_query($db, $sqlHT);
  if (mysqli_num_rows($haveT)) {
    echo '表存在...';
  } else {
    echo '表不存在...';
  }