how to delete data where number of days > 30
<p>i am new in php
i have a table </p>

<pre><code>+-----------------------------------------------------------------+
|                              seeker                             |
+----+-------+----------+---------------+-------------------------+
| id | name  | password | register_date | login_date | limit_date |
+----+-------+----------+---------------+------------+------------+
| 01 | ali   |   ****   |  2012-02-08   | 2012-02-09 | 2012-03-09 |
| 02 | hamza |   ****   |  2012-04-10   | 0000-00-00 | 0000-00-00 |
| 03 | sam   |   ****   |  2012-04-15   | 0000-00-00 | 0000-00-00 |
+----+-------+----------+---------------+------------+------------+
</code></pre>

<p>i have to apply two queries
one to delete data when limit date = current date</p>

<p>second to delete data when user login_date is '0000-00-00' and its (register_date - current date) >= 30</p>

<p>my first query is implementing properly</p>

<p>in my second query i am finding no of days by subtracting register_date from current date, if no of days greater than or equal to 30 then delete that user.</p>

<p>my problem is that when an any single user return no of days >= 30 then all user of login_date ='0000-00-00' get deleted.
 here is my code</p>

<pre><code>    //code for  delete user where (current date - register date)&gt;=30
    $qry="select * from seeker where login_date='0000-00-00'";
    $rs= mysql_query($qry, $con);
     $res=mysql_num_rows($rs);
    echo "total rows of zero dates "."".$res;
    echo "&lt;br&gt;";
    if($res!=0)
    {
        echo "user exist of date='0000-00-00'";
        echo"&lt;br&gt;";
        $qqq="select * from seeker where login_date='0000-00-00'";
            $rsq= mysql_query($qqq, $con);
            while($resq=mysql_fetch_array($rsq))
            //echo $resq;
        {
          $r=$resq['c_date'];
          echo $r;
          $reg_date = strtotime($r); 
          echo "&lt;br&gt;";

    //current date
        $c= date("Y-m-d");
        echo $c;
        //echo "current date".""."&lt;br&gt;";
        $current_date = strtotime($c); 
        echo "&lt;br&gt;";

         //date difference
          $datediff = $current_date - $reg_date;
          $days = floor($datediff/(60*60*24));
          echo "days"."".$days;
          echo "&lt;br&gt;";

        if($days&gt;=30)
        {
        $qry1="delete from seeker where $days = '30'";
        $rs1= mysql_query($qry1, $con);
        echo $qry1;
        echo "&lt;br&gt;";
        echo "&lt;br&gt;";
        }
      }

}
// code for delete user where current date = limit date
$qry3="select * from seeker where current_date = limit_date";
$rs3= mysql_query($qry3, $con);
$res3=mysql_num_rows($rs3);
if($res3!=0)
{

        $q= "delete from seeker where current_date = limit_date";
        $rq=mysql_query($q, $con);
        echo "$q";
        echo "&lt;br&gt;";
}
</code></pre>

<p>please tell me where i made mistake .
 i want to delete only that user whose days >=30, but it deleted all user of login_date ='0000-00-00'</p>

<pre><code>for example if current date is 2012-01-10. it will not delete user
if current date is 2012-05-10.. it must delete only "hamza" but it delets "sam" too 
</code></pre>

<p>please help me, i am student and new in php. thanks in advance</p>
