Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7910325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:49:45+00:00 2026-06-03T12:49:45+00:00

i am new in php i have a table +—————————————————————–+ | seeker | +—-+——-+———-+—————+————————-+

  • 0

i am new in php
i have a table

+-----------------------------------------------------------------+
|                              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 |
+----+-------+----------+---------------+------------+------------+

i have to apply two queries
one to delete data when limit date = current date

second to delete data when user login_date is ‘0000-00-00’ and its (register_date – current date) >= 30

my first query is implementing properly

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.

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

    //code for  delete user where (current date - register date)>=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 "<br>";
    if($res!=0)
    {
        echo "user exist of date='0000-00-00'";
        echo"<br>";
        $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 "<br>";

    //current date
        $c= date("Y-m-d");
        echo $c;
        //echo "current date".""."<br>";
        $current_date = strtotime($c); 
        echo "<br>";

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

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

}
// 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 "<br>";
}

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′

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 

please help me, i am student and new in php. thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:49:46+00:00Added an answer on June 3, 2026 at 12:49 pm

    Please try DATEDIFF(time1 ,time2) function and NOW() function in query as given below

    DELETE FROM seeker WHERE DATEDIFF( NOW( ) , `register_date` )  >= 30 AND 
    `login_date` = '0000-00-00'
    

    thanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to php and I have a table that displays cases
i am new in php, i have one table has customer_name how to get
I'm new to php and sql. I have a table with three columns. One
I'm new to MySQL and PHP. I have two tables, one to hold all
i am new in php i have a problem in my php code.please help
I'm quite new to php and have been reading Larry Ullman book to develop
I'm pretty new to PHP and have a String which contains an HTML page.
Hi I am new to PHP and have a simple problem but I have
I'm very new to PHP and I have a small task of displaying a
I am new to PHP and I have a problem in my code. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.