The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Newbie, Need help with simple script =)

Discussion in 'Database Discussions' started by Orsenfelt, Aug 7, 2008.

  1. Orsenfelt

    Orsenfelt Registered

    Joined:
    Aug 7, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi all, Let me start by saying that I am pretty much a total newbie when it comes to scripting etc, SO I think what I am trying to do is most likely very simple, I just can't get my head around it :D

    So, here is the situation.
    I'm working on a website idea of mine that is similar to the likes of Digg/Reddit in that the content is 'rated' up or down by the users.

    What I want to do is this.
    Create an automated script/cron job that will check the database for any content with a rating lower than say.. -25 and delete it. This will hopefully mean that any trash that gets voted way down will just get deleted =)

    The problem, I have no idea where to begin with this script.

    I think I am right in saying that I can set up the cron job in cPanel, I just point it to the script and set the time, right?
    After that.. I have no idea.


    Some extra info..

    The database is set up like so :

    table : DBName --> rash_quotes --> rating

    Thanks in advance for any help :D
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,451
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Indeed. Other than that, as far as the scripting of what you want to do, you'll do better on some other site that supports this sort of thing. cPanel forums is not the place for this though. What you want to do has nothing to do with cPanel other than the cron you can setup in your cPanel.
     
  3. phatrik

    phatrik Member

    Joined:
    Jul 27, 2008
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Toronto, ON



    Plain and simple you need to learn SQL. I've never scripted SQL personally, but just from seeing a few examples, you need to look at something like:


    Select * from TABLE_NAME_CONTAINING_RATINGS where NAME_OF_ROW_CONTAINING_RATING < 25; COMMAND TO DELETE SELECTION


    I'm sure the above is no where near being accurate but what you're asking sounds pretty basic.


    Select MATCH_PATTERN from TABLENAME where CONDITION


    Is a pretty basic thing in MySQL. Once you've figured out the select query, you'll then have to figure out a way to delete the results. Good luck :)
     
Loading...

Share This Page