title: PHP, get data from the database
body: <p>I want to retrieve data from a database with PHP and show it on a website.  </p>
  
  <p>This code does not work correctly.  I want to display all cars that are Chevy on my database.</p>
  
  <pre><code>&lt;?php
  $db = mysqli_connect("localhost","myusername",
  "mypassword","database");
  
  if (mysqli_connect_errno()) { 
      echo("Could not connect" .
        mysqli_connect_error($db) . "&lt;/p&gt;");
      exit(" ");
  }
  
  $result = mysqli_query($query);
  
  if(!$result){
    echo "&lt;p&gt; Could not retrieve at this time, please come back soon&lt;/p&gt;" .   
      mysqli_error($dv);
  }
  
  $data = mysql_query("SELECT * FROM cars where carType = 'Chevy' AND active = 1")
    or die(mysql_error());
  
  echo"&lt;table border cellpadding=3&gt;";
  while($row= mysql_fetch_array( $data ))
  {
    echo"&lt;tr&gt;";
    echo"&lt;th&gt;Name:&lt;/th&gt; &lt;td&gt;".$row['name'] . "&lt;/td&gt; ";
    echo"&lt;th&gt;ImagePath:&lt;/th&gt; &lt;td&gt;".$row['imagePath'] . " &lt;/td&gt;&lt;/tr&gt;";
    echo"&lt;th&gt;Description:&lt;/th&gt; &lt;td&gt;".$row['description'] . "&lt;/td&gt; ";
    echo"&lt;th&gt;Price:&lt;/th&gt; &lt;td&gt;".$row['Price'] . " &lt;/td&gt;&lt;/tr&gt;";
  }
  echo"&lt;/table&gt;";
  ?&gt;
  </code></pre>
  
  <p>How do I get data from the database with PHP?</p>