Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder Armondo's Avatar
    Join Date
    Feb 2007
    Posts
    144
    Thanks
    3
    Thanked 0 Times in 0 Posts

    automatically deleting rows

    is there a way i can automatically delete rows after the number of them reaches a certain number? like if the number of rows reached 160 it starts deleting the last row (oldest row) in the table? i am running a discussion board at www.flashanims.com and it has been producing lots of posts that i think are irrelevant after they hit the 10th page...so any help on this? I'm using phpmyadmin if your wondering.
    ..
    ▲ ▲

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    you would have to run a cron job.

  • #3
    Regular Coder Armondo's Avatar
    Join Date
    Feb 2007
    Posts
    144
    Thanks
    3
    Thanked 0 Times in 0 Posts
    ummm? cron job? please enlighten me
    ..
    ▲ ▲

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    a cron job is a script that runs on your system at a specifically scheduled time. you would write the script and have it clean up your data.

    really though your data is not significant in size and doesn't even need to be deleted.

    what you should do is use a LIMIT clause on your query to only return so many rows related to a topic.

  • #5
    Regular Coder Armondo's Avatar
    Join Date
    Feb 2007
    Posts
    144
    Thanks
    3
    Thanked 0 Times in 0 Posts
    lemme throw a screw ball in here: here is my code
    PHP Code:
        $page $_GET['page']; 
        
    $limit 10
        
    $result mysql_query("select count(*) from comtbl"); 
        
    $total mysql_result($result00); 

        
    // work out the pager values 
        
    $pager  Pager::getPagerData($total$limit$page); 
        
    $offset $pager->offset
        
    $limit  $pager->limit
        
    $page   $pager->page

        
    // use pager values to fetch data 
        
    $query "select * from comtbl order by postID DESC limit $offset, $limit"
        
    $result mysql_query($query); 
    this code is the pagination code i use, nevermind the class it goes with as it is not important. i already set the limit of posts it displays per page...but how would i limit the amount of pages it gets total?
    ..
    ▲ ▲

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Well this wouldn't be a MySQL issue at this point. You would want to ask this in the PHP forum. And I don't think thats going to be enough information to answer your question. We'll have to see what those functions are actually doing in your paging class file.

    I'd suggest looking at the $page and $offset variables in your class file for clues.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #7
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    moving to PHP forum.

  • #8
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
        $max_pages 5;
        
    $limit 10
        
    $max_rows $max_pages $limit;
        
    $result mysql_query("select count(*) from comtbl LIMIT ".$max_rows); 
        
    $total mysql_result($result00); 
    That should limit your count and therefore limit your results returned and limit the amount of pages you end up with.

    Anyway good luck.

  • #9
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Or you can add in a search criteria with dates. Show all topics greater then 30 days, 60 days... w/e. Thats how vbulletin (this board) does it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •