Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom php forum - showing new/unread posts

Tags:

I have written myself a custom forum script using php. I decided against using phpbb and others as I wanted 100% flexibility with what I was doing.

I've hit a problem though:

How do I show a user if a post is new/unread or not.

Two solutions come into mind:

1) Cookies 2) Database

I don't want to use cookies because they can be deleted by the user and the firefox side of things means they are auto deleted. Either way, I don't want to use cookies.

The database is causing me a problem because I can't seem to get the database structure sorted in my head! The first solution I could think of was:

  • When a user loads the forums up, check the last time they loaded the forums up
  • Check all the posts have been made since they last viewed the forums
  • Enter those values into the database in a table with fields (user_id, post_id).
  • that value is then deleted from the database when they view the post

The problems I am thinking with this is it's a huge database drain. It seems SO inefficient. I'm sure there are methods with arrays in fields, but I'm not really that good with arrays.

Could anyone give me an indication of a good database design for this as well as any code that has to go with it? It's driving me crazy as I just can't think of a solution that's good and efficient with the server.

Thanks a lot in advance for your help and assistance,

James.