title: PHP: javascript alert, with value from sql query, into IF condition
body: <p>With the following code, a popup table should appear with sql query data, only when retrieved records are greater than 1.</p>
  
  <pre><code>$sql = "SELECT * FROM pt_locations WHERE country = ('$countryCode') AND location = ('$cityCode')";
  $result = $conn-&gt;query($sql);
  
  $rowcount=mysqli_num_rows($result);
  
  $message = "Records found: " . $rowcount . "&lt;br /&gt;&lt;br /&gt;";
  
  if ($rowcount &gt; 1) {
  
  echo '&lt;script language="javascript"&gt;';
  echo 'alert' .$message;
  
  foreach($result as $val){ 
  
  $id_country = $val["country"] ;
  $id_code = $val["code"] ;
  $id_location = $val["location"] ;
  $id_latitude = $val["latitude"] ;
  $id_longitude = $val["longitude"] ;
  
  echo "&lt;table border='1' cellpadding='5'&gt;";
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;&lt;i&gt;&lt;strong&gt;ID Code&lt;/strong&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;";
  echo $id_code."&lt;/td&gt;";
  echo "&lt;td&gt;&lt;i&gt;&lt;strong&gt;Country&lt;/strong&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;";
  echo $id_country."&lt;/td&gt;";
  echo "&lt;td&gt;&lt;i&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;";
  echo $code."&lt;/td&gt;";
  echo "&lt;td&gt;&lt;i&gt;&lt;strong&gt;Location&lt;/strong&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;";
  echo $id_location."&lt;/td&gt;";
  echo "&lt;td&gt;&lt;i&gt;&lt;strong&gt;Latitude&lt;/strong&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;";
  echo $id_latitude."&lt;/td&gt;";
  echo "&lt;td&gt;&lt;i&gt;&lt;strong&gt;Longitude&lt;/strong&gt;&lt;/i&gt;&lt;/td&gt;&lt;td&gt;";
  echo $id_longitude."&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  echo "&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;";
  } 
  echo '&lt;/script&gt;'; 
  }
  </code></pre>
  
  <p>Recording counts are done correctly, but I can not make the popup appear in any way.</p>