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 8953179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:02:54+00:00 2026-06-15T14:02:54+00:00

I’m in a deep s**t and need help from smart fellows like you. Here

  • 0

I’m in a deep s**t and need help from smart fellows like you.

Here is some info about software and technologies I use: cPanel, Linux server, phpMyAdmin, MySQL.

I need to delete some records from a table on a daily basis. I do it normally by using Select statement on phpMyAdmin and then delete all the records.

*

Select `user_id` FROM `user`
WHERE EXISTS ( SELECT `user_id`
FROM `userinfo`
WHERE `essay` like '% yahoo %' AND user.user_id = userinfo.user_id)

*

The above code basically searches for specific words in userinfo table and displays their corresponding user_id in user table, which I then delete manually. In this particular case the search term is ‘yahoo’. I search for all the users who have the word ‘yahoo’ in their profile’s essay and delete them from user table.

The problem is I’ve got way too many search terms to do it manually.

I would love to have it written in php file and run through cron if it’s possible. Would be nice to have a field or fields on php file where I would type all possible search words/phrases then the code would execute all of them one after another.

I’ve heard it’s possible to use cron jobs for that, read some articles about them but have absolutely no idea how to handle it.

Your help would be much appreciated and please tell me if it’s unclear.
Regards,
Igor

  • 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-15T14:02:55+00:00Added an answer on June 15, 2026 at 2:02 pm

    This should at least get you started. Keep in mind I don’t know the structure of your DB so you may have to change some things. Also this is by FAR not the most efficient way to do it, but it is easy to follow, you can do this in a single MySQL query instead of looping over each user id (which I show an untested example of see —faster way—), but again I don’t know about your DB structure so you’ll have to play with it, plus this way does exactly what you do now, one at a time so hopefully it’s easier to follow and you can mod it to be more efficient later. Backup your db before playing with this.

    PHP script to do what you want:

    <?php
    //put your search terms in this array
    $search_terms = array('yahoo', 'google', 'bing');
    
    //conenct to your DB
    $db_conn = mysql_connect('yourdbhost', 'yourdbuser', 'yourdbpassword');
    mysql_select_db('yourdbname', $db_conn);
    
    //query the db for each search term
    foreach($search_terms as $search_term) {
        //----slow but clear way----    
        $result = mysql_query("SELECT user_id 
                            FROM user
                            WHERE EXISTS (
                                SELECT user_id
                                FROM userinfo
                                WHERE essay like '%{$search_term}%' 
                                AND user.user_id = userinfo.user_id)", $db_conn);
    
        //for eachr user id returned, delete them from your users table 
        //as you would have done manually. I don't know about your users
        //table so you will have to edit this query as you see fit.
        while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $user_del_result = mysql_query("DELETE FROM user 
                                            WHERE user_id = {$row['user_id']}
                                            LIMIT 1", $db_conn);
            //might want to check here to see if the query executed successfully
        }
    
        //----faster way----
        $result = mysql_query("DELETE FROM user
                                WHERE EXISTS (
                                SELECT user_id
                                FROM userinfo
                                WHERE essay like '%{$search_term}%' 
                                AND user.user_id = userinfo.user_id)", $db_conn);
    }
    ?>
    

    To call it periodically you need to have a look at cron jobs (read this) and then just call the PHP script periodically with something like this in your crontab (this would run once per day at midnight for instance):

    0 0 * * *   /path/to/php-cli /path/to/the/above/php/file.php
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Silverlight experts out there, I need some help. I used Deep Zoom Composer to
I need some help programatically setting the selected item in a combobox. I've got
I want to make a deep copy method. I seeked help here the other
I need some help understanding how javascript protoypal inheritance works... or rather why its
I need some help optimizing some queries for my database. I do understand the
I need to copy an object that has a pretty deep hierarchy of member
Say we have deep hashes like: b = {1 => {2 => {} },
I would like to deep clone a List. for that we are having a
I want to use deep zoom in Silverlight, but it seems that the images
I am a .net beginner. I need to add some data to xml file

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.