title: PHP counting Male and Female in the database to CHART
body: <p>I'm using <code>libchart</code> in my <code>PHP</code> but I have problem on how I can count the males and females in my Database. I'm using <code>wampserver</code>: </p>
  
  <pre><code>&lt;?php
      include "../libchart/libchart/classes/libchart.php";
  
      define('DB_HOST', 'localhost');
      define('DB_NAME', 'login');
      define('DB_USER','root');
      define('DB_PASSWORD','');
  
      $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to                                        MySQL: " . mysql_error());
      $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
  
      header("Content-type: image/png");
  
      $chart = new PieChart(500, 300);
      $query1= "Select count(*) from users where gender='Male'";
      $query2= "Select count(*) from users where gender='Female'";
      $male=$query1;
      $female=$query2;
      $dataSet = new XYDataSet();
      $dataSet-&gt;addPoint(new Point("Male", $male));
      $dataSet-&gt;addPoint(new Point("Female", $female));
      $chart-&gt;setDataSet($dataSet);
  
      $chart-&gt;setTitle("Number of Female and Male");
      $chart-&gt;render();
  
  
  ?&gt;
  </code></pre>