title: Select specific duplicate database values and display the count
body: <p>I've tried a million different ways, and this is probably something super simple, but I can't get it figured out.</p>
  
  <p>I have a database that displays several different columns (name, age, gender, breed, player, etc.)</p>
  
  <p>What I would like is to include a line that states "We have ___ number of female characters."</p>
  
  <p>Here is my entire page where I want it displayed:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
   &lt;title&gt;AUSUS --- mythical equine RPG&lt;/title&gt;
   &lt;link rel="stylesheet" type="text/css" href="/css/evolution2.css" /&gt;
  &lt;link href='http://fonts.googleapis.com/css?family=Vollkorn:400,400italic,700,700italic|Kreon:400,700,300|La+Belle+Aurore|Stalemate|IM+Fell+English:400,400italic|Mrs+Saint+Delafield' rel='stylesheet' type='text/css'&gt;
   &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h1&gt;Character Database&lt;/h1&gt;
  
  
  &lt;p&gt;
  We currently have &lt;b&gt;
  
  &lt;?php
  
  $link = mysql_connect("***", "***", "***");
  mysql_select_db("tarb89_characters", $link);
  $result = mysql_query("SELECT * FROM characters", $link);
  $num_rows = mysql_num_rows($result);
  echo "$num_rows";
  
  ?&gt;
  
  &lt;/b&gt;
  characters listed in the database.  You may search the character database by character name or player name.  Dams and sires marked with an asterisk (*) are from &lt;b&gt;outside&lt;/b&gt; Ausus.&lt;br&gt;&lt;br&gt;
  
  
  
  
   &lt;br&gt;&lt;br&gt;
  &lt;form action="searchchars.php" method="GET"/&gt;
  &lt;input type="text" name="searchchars" /&gt;
  &lt;input type="submit" name="submit" value="Character Name Search" /&gt;&lt;br&gt;
  &lt;/form&gt;
  &lt;br&gt;
  &lt;form action="searchplays.php" method="GET"/&gt;
  &lt;input type="text" name="searchplays" /&gt;
  &lt;input type="submit" name="submit" value="Player Name Search" /&gt;
  &lt;/form&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;?php
  /// In order to use this script freely
  /// you must leave the following copyright
  /// information in this file:
  /// Copyright 2012 www.turningturnip.co.uk
  /// All rights reserved.
  
  include("connect.php");
  
  if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
  $start_from = ($page-1) * 20; 
  $result = mysql_query("SELECT * FROM characters ORDER BY name ASC LIMIT $start_from, 20");
  $num = mysql_num_rows ($result);
  
  if ($num &gt; 0 ) {
  $i=0;
  while ($i &lt; $num) {
  
  $id = stripslashes(mysql_result($result,$i,"id"));
  $name = stripslashes(mysql_result($result,$i,"name"));
      $breed = stripslashes(mysql_result($result,$i,"breed"));
      $gender = stripslashes(mysql_result($result,$i,"gender"));
      $color = stripslashes(mysql_result($result,$i,"color"));
      $markings = stripslashes(mysql_result($result,$i,"markings"));
      $genetics = stripslashes(mysql_result($result,$i,"genetics"));
      $player = stripslashes(mysql_result($result,$i,"player"));
      $traits = stripslashes(mysql_result($result,$i,"traits"));
      $defects = stripslashes(mysql_result($result,$i,"defects"));
      $extras = stripslashes(mysql_result($result,$i,"extras"));
      $profile = stripslashes(mysql_result($result,$i,"profile"));
      $dam = stripslashes(mysql_result($result,$i,"dam"));
      $sire = stripslashes(mysql_result($result,$i,"sire"));
      $status = stripslashes(mysql_result($result,$i,"status"));
  
  $row .= '
  
  &lt;h5&gt;'.$name.'&lt;/h5&gt;
  
  &lt;table width="550px" cellpadding="5" cellspacing="20" style="background: #eeeeee; border-radius: 15px; border: 1px solid #5067be;"&gt;
  &lt;tr&gt;
  &lt;td width="50%"&gt;&lt;p&gt;
      &lt;b&gt;ID Number:&lt;/b&gt;  '.$id.'&lt;br&gt;
      &lt;b&gt;Breed:&lt;/b&gt;  '.$breed.'&lt;br&gt;
      &lt;b&gt;Gender:&lt;/b&gt;  '.$gender.'&lt;br&gt;
      &lt;b&gt;Dam:  &lt;/b&gt;'.$dam.'&lt;br&gt;
      &lt;b&gt;Sire:  &lt;/b&gt;'.$sire.'&lt;br&gt;
      &lt;b&gt;Status:  &lt;/b&gt;'.$status.'&lt;br&gt;
      &lt;b&gt;Profile:&lt;/b&gt;  &lt;a href="'.$profile.'"&gt;Click Here&lt;/a&gt;&lt;br&gt;
      &lt;b&gt;Player:&lt;/b&gt;  '.$player.'&lt;/p&gt;&lt;/td&gt;
  &lt;td width="50%"&gt;&lt;p&gt;        
      &lt;b&gt;Color:&lt;/b&gt;  '.$color.'&lt;br&gt;
      &lt;b&gt;Genetics: &lt;/b&gt;'.$genetics.'&lt;br&gt;
      &lt;b&gt;Markings:&lt;/b&gt;  '.$markings.'&lt;br&gt;
      &lt;b&gt;Traits:&lt;/b&gt;  '.$traits.'&lt;br&gt;
      &lt;b&gt;Defects:&lt;/b&gt;  '.$defects.'&lt;br&gt;
      &lt;b&gt;Extras:&lt;/b&gt;  '.$extras.'&lt;/p&gt;&lt;/td&gt;
      &lt;/table&gt;&lt;br&gt;
  
      ';
  
  
  
  
  
  
  ++$i; }} else { $row = '&lt;tr&gt;&lt;td colspan="2" align="center"&gt;Database empty.&lt;/td&gt;&lt;/tr&gt;'; }
  
  mysql_close();
  ?&gt;
  
  &lt;? echo $row ?&gt;
  &lt;/p&gt;&lt;center&gt;
  &lt;font face="tahoma" style="font-size: 12px;"&gt;Pages: 
  &lt;?php
  include("connect.php");
  $result = mysql_query("SELECT COUNT(name) FROM characters");
  $row = mysql_fetch_row($result);
  $total_records = $row[0];
  $total_pages = ceil($total_records / 20);
  
  for ($i=1; $i&lt;=$total_pages; $i++) {
          echo "&lt;a href='index.php?page=".$i."'&gt;".$i."&lt;/a&gt; | ";
  };
  ?&gt;
  &lt;/center&gt;&lt;/font&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>