svgmx5 Posted December 21, 2010 Share Posted December 21, 2010 i have this small problem trying to update the database.... what i have is a members site in which they can view a variety of topics, however i want the user to be able to say delete a topic they are not interested in but still keep that topic open to other users who have not blocked it I'm tying to figure out how to do this, i initially had the following code: $update_db = mysql_query("UPDATE topics SET view='2' WHERE topicID='$topicID'") or die(mysql_error()); I had it set to to 2 meaning that all the topics that were set to 1 were visible to the user, only those they blocked were set to 2 and only be blocked to those users who blocked them not everyone The problem with that was that it blocked it to everyone Can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/222271-need-help-updating-a-database/ Share on other sites More sharing options...
denno020 Posted December 21, 2010 Share Posted December 21, 2010 You need to add this information in the users table. I imagine it would be very involved to get the functionality you're after though.. Here is how I would approach it: If a user presses delete, instead of changing the values in the topics table, add a value to the users table (in a new table field), which will keep track of which topic numbers they've 'deleted'. Every time a topic is deleted, append its topic number to this field. You will parse this field, and break it up to get each individual topic number, and make sure it isn't shown to the user. Alternatively, you could add another field to your topics table, that will keep track of which users have 'deleted' the topic. Append each user to that field. Parse the field to get each user's id, and make sure it doesn't get displayed to them in the future. Hope that helps Denno Quote Link to comment https://forums.phpfreaks.com/topic/222271-need-help-updating-a-database/#findComment-1149785 Share on other sites More sharing options...
topcat Posted December 21, 2010 Share Posted December 21, 2010 I'd actually take that a step further and create a third table with a many to many relationship with columns user_id | topic_id | status. That way you don't have to parse anything and you can let the SQL do the work. Quote Link to comment https://forums.phpfreaks.com/topic/222271-need-help-updating-a-database/#findComment-1149804 Share on other sites More sharing options...
svgmx5 Posted December 22, 2010 Author Share Posted December 22, 2010 so basically create a table where it will store all the topics that the users have removed from their view. And in that table it will save the topic id, userID and status? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/222271-need-help-updating-a-database/#findComment-1150213 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.