title: How do I total up "yes's" from a column, by a userlevel and only for the past week? Using PHP and SQL
body: <p>I hopefully have a simple question I just cannot get anything I try to work. </p>
  
  <p>Basically I am looking for a way to simply count the yes's in each column where user level = a number and by username = a user name in the past week starting on monday. Also for a way to total the amounts in the amounttot column. </p>
  
  <p>My SQL Database is set up like below:</p>
  
  <p><strong>DB Name</strong>: 1_1 <strong>Table:</strong> form_2</p>
  
  <p><em>Sample of data in DB</em></p>
  
  <pre><code>username userlevel inspect signatu claimnum amounttot timestamp
  -------- --------- ------- ------- -------- --------- ---------
  BobS     7         yes     yes     kj98739  5388.00   2011-10-15 16:39:20
  SteveN   8         yes     no      kj76739  5000.00   2011-10-15 15:29:00
  TimK     7         no      yes     kj98734  6000.00   2011-10-15 14:35:06
  </code></pre>
  
  <p>How I have it list all data per team, I just need to get totals below this print out in a completely different table I can just place below it., how can I get this to only show the last weeks data starting on a monday:</p>
  
  <pre><code>&lt;?php
  $con = mysql_connect("localhost","1_1","XXXXXXXXXXXXXXXX");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("1_1", $con);
  
  $result = mysql_query("SELECT * FROM form_2 WHERE userlevel = '5' ORDER BY timestamp DESC");
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;&lt;font size='1'&gt;Name&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Latitude&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Longatude&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Inspect&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Sig&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Phone #&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Insur&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Claim&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Appr&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;AdjusApp&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Check&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Amount&lt;/th&gt;
  &lt;th&gt;&lt;font size='1'&gt;Time&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysql_fetch_array($result))
    {
    echo "&lt;tr&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['username'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['lat'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['longa'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['inspect'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['signatu'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['gotphone'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['hain'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['claimnum'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['approved'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['adjustapprov'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['checkcollec'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['amounttot'] . "&lt;/font&gt;&lt;/td&gt;";
    echo "&lt;td&gt;&lt;font size='1'&gt;" . $row['timestamp'] . "&lt;/font&gt;&lt;/td&gt;";
  
    echo "&lt;/tr&gt;";
    }
  echo "&lt;/table&gt;";
  
  mysql_close($con);
  ?&gt; 
  </code></pre>
  
  <p>Any help would be greatly appreciated. Thank you. </p>