epicpete Posted May 26, 2009 Share Posted May 26, 2009 Hey, I'm currently working on a site whereby users can comment on images and videos in a youtube style way. At some point I'm going to implement a way for users to post videos and images but I haven't done this yet. Videos are navigated to by video?id="videoid" Images are navigated to by image?id="imageid" I plan to make a comment section on each page, what i'm wondering is how sites of this type store comments. I could give each video/image a new table but this could be hard to control considering at some point users will be able to submit there own resulting in new tables. Is it possible to store comments in another way - like a comma separated list in the style: user,comment,user,comment, If so how would I do this using a 'for each'? $a = split(',', $row['comments']); foreach ($a as $value) { echo("$value"); } the code above only grabs the comment. Is there a way I can make it give say $a the value of a user, then $b a value of comment? If I could get this to work it would mean I could just have one table for the video/image with fields 'name','desc','videoid','comments' which would be ideal I hope you see where i'm coming from Thanks in Advance Pete Quote Link to comment https://forums.phpfreaks.com/topic/159753-comments-on-individual-pages/ Share on other sites More sharing options...
mikr Posted May 26, 2009 Share Posted May 26, 2009 If I understand you right, you have a video table with the following fields: name desc videoid comments And you want comments to contain a comma delimited list of user id and comments. So, what if the user's comments contain commas? Having worked with csv situations, I always aim to avoid them when possible, so here's a suggestion... Why don't you create one new table (that's all you need) with the following columns: id, datetime, fk_video_id, user_id, comments Then you can have multiple comments for each video, and you can timestamp em and it makes it easier to delete unwanted messages. Quote Link to comment https://forums.phpfreaks.com/topic/159753-comments-on-individual-pages/#findComment-842605 Share on other sites More sharing options...
RussellReal Posted May 26, 2009 Share Posted May 26, 2009 no... you'd want a table like this: comment_id |comment_by_id |comment_to_video_id |comment |comment_rating_up |comment_rating_down Quote Link to comment https://forums.phpfreaks.com/topic/159753-comments-on-individual-pages/#findComment-842659 Share on other sites More sharing options...
epicpete Posted May 26, 2009 Author Share Posted May 26, 2009 Thanks, great idea - I can't believe I didn't think of making a separate table for comments. Thanks Again Pete Quote Link to comment https://forums.phpfreaks.com/topic/159753-comments-on-individual-pages/#findComment-842669 Share on other sites More sharing options...
RussellReal Posted May 26, 2009 Share Posted May 26, 2009 anytime bro, click 'solved' please Quote Link to comment https://forums.phpfreaks.com/topic/159753-comments-on-individual-pages/#findComment-842684 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.