title: Send email to recipients in MySQL DB using PHP
body: <p>I'm working on a website in which, when a person enters email in the box, it will save it to MySQL DB.</p>
  
  <p>I want to make a page, when once visited, will send email to the recipents in the DB. My script is here:</p>
  
  <pre><code>$servername = "localhost";
  $username = "username";
  $password = "password";
  $dbname = "dbname";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  $sql = "SELECT email FROM subscribers";
  $result = $conn-&gt;query($sql);
  
  if (mysqli_num_rows($result) &gt; 0) {
      // output data of each row
      while($row = mysqli_fetch_assoc($result)) {
         echo $row["email"]. "&amp;nbsp";
      }
  } else {
      echo "0 results";
  }
  
  $to = "";
  $subject = "PrakashSoft Website has been Lauched!";
  $txt = "Respected Mam/Sir,
  
      PrakashSoft Website has been lauched from 3rd May 2015! To visit the website use the following link:
  
      http://www.prakashsoft.esy.es/home.php";
  $headers = "From: noreply@prakashsoft.esy.es";
  
  mail($to, $subject, $txt, $headers);
  $conn-&gt;close();
  </code></pre>
  
  <p>So, I'm trying <code>$to</code> to get those multiple emails from DB and then sending them an email which I've typed. What should I do to do that? I know I've left <code>$to = "";</code> blank.</p>