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

  • SEARCH
  • Home
  • 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 6577365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:37:34+00:00 2026-05-25T15:37:34+00:00

I have a button that will delete all users that fits into this query:

  • 0

I have a button that will delete all users that fits into this query:

DELETE FROM users WHERE lastlogin < ".time()." - ".$sdata['activitylimit']."*3600

Although, I have to take some parts of each users data, and put it into another table (“username” and “email”)

How can I take the users username AND email from the table users, and insert it into my table “reserved_data”?

The table reserved_data looks like this:

id (just the id)
data (the email or username value)
type (what type of data is it((username/email)))
  • 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-05-25T15:37:34+00:00Added an answer on May 25, 2026 at 3:37 pm

    You can’t do that directly, thanks to the table layout of the reserved_data table. Why do you do that? Why haven’t you got a deleted_users table, containing their username and email? That way you could do this:

    $q1 = "INSERT INTO deleted_users (username, email) SELECT username, email FROM users WHERE lastlogin < (".time()." - ".$sdata['activitylimit']." * 3600)";
    
    $q2 = "DELETE FROM users WHERE lastlogin < (".time()." - ".$sdata['activitylimit']." * 3600)";
    

    If you won’t change the table, use something like this:

    $toDelete = mysql_query("SELECT username, email FROM users WHERE lastlogin < (".time()." - ".$sdata['activitylimit']." * 3600)");
    
    while($user = mysql_fetch_assoc($toDelete))
    {
        mysql_query("INSERT INTO reserved_data (`data`, `type`) VALUES ('" . $user['username'] . ", 'username'");
        mysql_query("INSERT INTO reserved_data (`data`, `type`) VALUES ('" . $user['email'] . ", 'email'");
    }
    
    // Now perform the delete
    mysql_query("DELETE FROM users WHERE lastlogin < (".time()." - ".$sdata['activitylimit']." * 3600)");
    

    You see the latter requires more code and is generally a bad idea. You lose the relation between a username and its email address.

    Besides, you might want to use transactions, since it’s possible for one to not be included in the first query but be included in the second query. You then lose this user’s data.

    And perhaps you can fix all your problems by simply adding an (in)active column to your users table. One rarely wants to really delete data.

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

Sidebar

Related Questions

I have a button that when clicked will run a stored procedure on a
I have a button on an ASP.Net page that will call Response.Redirect back to
I have a button that, when pressed, will add a new HTML row. Within
I currently have a simple form that when you click the save button will
We have a button that saves asynchronously using AjaxToolKit/C#/.NET. I'm getting this in my
I have the following PHP function which will list the users from a MySql
I have this function that is supposed to query the database every 4 seconds
I have a button that I would like to disable when the form submits
I have a Button that is looking at 2 comboboxes to make sure they
I have a button that I'm creating in a UIViewController like so: TOLoginButton* button

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.