I have my forum limited to 30 topics a page. I want it to also limit to 4 pages, therefore deleting any topics and replys after those 4 pages. How would I do that? Here is the select query atm $query="SELECT * FROM `topics` WHERE `forum`='$forum' AND important='0' AND sticky='0' ORDER BY `lastreply` DESC LIMIT $forum_look, $forum_count"; PHP: EDIT: My forum already has $forum_look and a $forum_count set. It is set to show 30 topics per page, then shows a next and previous button to go to the next or previous page. At the moment it displays as many pages with 30 topics per page. But i want to limit it to 4 pages, which would be 120 topics, then I want it to delete any topics after that.
not sure if i understood you correct but could something like this work? if ($forum_look>120) { $forum_count=0; } $query="SELECT * FROM `topics` WHERE `forum`='$forum' AND important='0' AND sticky='0' ORDER BY `lastreply` DESC LIMIT $forum_look, $forum_count"; PHP:
No sorry if I i didn't explain enough, I just can't think of a good way to explain it. My foum already have $forum_look and a forum $count_set. It is set to show 30 topics per page, then shows a next and previous button to go to the next or previous page. At the moment it displays as many pages with 30 topics per page. But i want to limit it to 4 pages, which would be 120 topics, then I want it to delete any topics after that.
Don't see the point of it but I understand what are you looking for. $query="DELETE FROM `topics` WHERE `forum`='$forum' AND important='0' AND sticky='0' ORDER BY `lastreply` DESC OFFSET 120"; PHP: I would be very careful when using this. This will permanently delete entries from the db. USE AT OWN RISK
Did you build your own forum? If yes: how did you build it and can't solve a problem like this? If not: doesn't it come with configurable settings / administration features? I'd recommend you not to delete content from the database, just mark it as unpublished. In this case if something important get's deleted you can always reactivate it
It's not a very important forum, its just a basic chat forum, and the reason I want to do this is because topics that are over at least 120 are old. I did not build it all myself but did most of it. I know alot of php but there are still some things I have not learned. Thanks for your help
I would recommend adding a field named 'active' to that table and toggling it to 0/1 depending on if you want it to display or not.
No, I actually want to delete all topics after the 4th page, I know 100% that I want them to delete, because they are old topics. I just want to know how to do that, not how you think i should do it, please Thank you
assuming this is the query that pulls the 120 discussions you want to keep SELECT id FROM `topics` WHERE `forum`='$forum' AND important='0' AND sticky='0' ORDER BY `lastreply` DESC LIMIT 120 Code (markup): you should run a delete query like this: DELETE FROM topics WHERE id NOT IN (SELECT id FROM `topics` WHERE `forum`='$forum' AND important='0' AND sticky='0' ORDER BY `lastreply` DESC LIMIT 120) Code (markup): ATTENTION: make sure you verify that the internal query retrieves the correct discussions and make a backup before 'testing' if it works correctly