how to set comment as unread/read with multiple users - php

i have a development blog in my project.i want add facility of set comment as unread for user until he/she see the comment.
suppose admin post a comment so for all users in that project should get that comment as unread
can anyone help
should i use $_SESSION or i have to use database tables?

You should use Database. Create 3 tables at least: user, comment, userReadComment since user read comment is a multi-to-multi relationship.

This calls for a proper design of the project.
What do you mean by :
i want it in php code...can any one help....i m totally stuck
?
You have to use Database only. It is as simple as this, once you have the comment table where you refer its ID and along with that you do user ID... if it is present, its read else, it isn't!
Or
You can set an enum of read or unread.
Can you show what have you done so far?

Related

General questions about database

I would like to create e-learning platform. So users will have a lot of things to choose (mostly available to view only for them) like:
add note
add movies to favorite
rate the instructor
And few options that auto save for each user like:
unanswered questions
wrong answer questions
movies in progress (user saw only 2 min from 5)
So what database or method I schould use for store that kind of data?
I do not want to use cookies because it needs to be save on user account and not on browser. User need to have that all on every browser or mobile device.
I wondering about json but...if I do so each user I'd will be available to view...so schould I use MySQL?
I would recommend that you build your own data logger, what i mean by this is build yourself a place to store every users data like an eManager if you would like.
Once this has been built you can then assign the eLearning courses using an ID to each of the users profile on your "eManager". Allowing you too keep track of each users progress etc.
The "eManager" could also save the users notes/wrong answers/unanswered questions, you could create surveys with a slider rating to rate the user. Honestly the limit is endless.
You can receive the data in two different ways:
(Personal) Either you can request that your users email you requesting a username and you generate a password and send it out to the user.
(Commercial) You build your eManager to recieve the data from the website which isnt too difficult to do.
It will be a long process and to answer your question in a different view practice SQL/PHP that would be your base make sure you can run more advanced query's and can confidently edit your DB etc.
Anymore questions just let me know, thanks.

How to build chat rooms attached for a single user profile?

I have a simple php user profile system that works like this: When user is registered he gets a specific url ?user. Therefore, other visitors can access his page.
What I want it to include chat application on users profile pages. But, every single user should have its own chat.
Which approach is the best, as I am a beginner in this? Should I put the messages from chat into the database or should I work with some log.txt files?
Any good tutorial for this would be helpful.
I found some tutorial for you: http://tutorialzine.com/2010/10/ajax-web-chat-php-mysql/
- looks like it could help you.
The only thing you need to adjust is to add room column in WEBCHAT_LINES table - that will be the unique name of the user, into which's chat room the chat line belongs. Then, when new chat line will be sent, you must save it to DB with apropriate room identificator. When you display the messages in chat, you must filter the results in each room to show only the lines for this particular room.
If you haven't use database before, there are plenty tutorials about mysql around the internet - it's not that difficult.
Good luck! And use Google when you'll have some doubts.

PHP newsfeed from people that you follow

So I'm building a music social network in PHP and now I'm stuck at the newsfeed. It should work just as any other newsfeed (Twitter, Facebook ...) and at first point it should be as simple as possible.
I don't have any problem with displaying all the posts from my MySQL database from newest to oldest, but I only want to show posts by users that I follow.
I don't need exact code, just a theoretical explanation how to do it.
I have two MySQL tables - users and posts. Do I need anything else?
Thank you!
Save the user id of the users. Build an API to retrieve the information. Save it into your database and retrieve the info via ajax every minute or so. Simple.
Keep track of which users follow who, then retrieve the posts of the users that the current logged in user is following.
You dont need new tables for this, add a new column in your users table that holds an array of id's of the users you re following. And in your posts table a column which holds the id of the user to who the post belong.

I am creating a Like button similar to Youtube or Facebook and I am having some trouble with storing unique likes

I have not started creating the code so I don't have anything to show, but what I am going to create is a simple button after each post on my website that allows users to "Like" the post. The only problem I have is figuring out what my MySQL table should look like for this feat. I want to add a 'rating' column in my 'tbl_posts' table that stores the count, but I'm not sure how to make it so that each user can only upvote the post once. Any ideas on how to create the database in this way?
Also, I want to create the "Like" button using jQuery. What do you recommend is the best way to create the Like button.
Gracias.
If you're talking about registered users on your page you could create a user_likes_post m:n relation between your post and user tables.
If you're talking about page visitors you'll have to resort to IP addresses and/or cookies to make sure everyone can upvote only once.
For the button itself i'd recommend jQuery UI
I recommend the best way to implement your like button is not to develop a new button, but to use the API:s of facebook to do that.
If you really feel the need to implement it yourself, you should have a UNIQUE column with user id in your SQL table.

Database / Schema structure to build a Wall system

I've been doing some researches about how to build a wall system similar to FB in PHP.
We planned to use an ODM (Mandango, MongoDB) instead of a regular ORM (MySQL) to achieve this. Some friend told me about inbox/outboxes system.
Inbox are all the messages that friends posts to your wall
Outbox are all the message you post
Why that ? Because it'll be simplier if you follow an user, you'll follow only his "outbox"
Each time i'll post something to my wall, this message will be duplicated to each of my followers (which will generate a lot of data).
But what about when a friend comments my post. On which entity is he going to comment my post ? Mine or his (because the content is duplicated) ?
What do you think ?
Have you already thought of this kind of question ? Have you any answers ?
Thanks
This is all about how you set up your database. I only have limited experience with MySql, so my answer relates to that. In this situation I would have at least these three tables:
-Users (with a unique id associated with each one)
-Messages: this includes both "inbox" and "outbox" messages. The reason you can put them all in one table is because if you're following someone, it will only pull those messages that have the (this is once column) "originating user id" and (this could be another column) "receiving user id" or some such thing. How you handle the data would all be done with php or asp or what have you.
-Comments: this holds all comments for all posts, and includes a column for the unique id of the message it relates to.
One thing to keep in mind when developing your system is that you never want to duplicate data. So, when you post to your wall, you don't want to actually create duplicate messages in your database for all the people who are following you, you want php to handle disseminating that information for you.

Categories