LanceyDavid Posted December 16, 2010 Share Posted December 16, 2010 Hello everyone, This is my first post and i have a question that im sure is easy to answer, im a beginner in PHP and i know how to submit a form and so on into mysql, now my question is, for everything i submit i would like for it to organize by date just like www.WorldStarHipHop.com, but not sure on how to do it. Any Clue? how do i get each indivual form i submit to automatically appear with the correct date untop? and how do i make the date appear untop of each section? Thanks for your time! Quote Link to comment Share on other sites More sharing options...
PnzrDrgoon Posted December 16, 2010 Share Posted December 16, 2010 When you insert into the table make sure you have a field for date_inserted set to a timestamp. Then when you fetch the records with your SQL order by date_inserted. Also it may help to have an index on that table by date_inserted. Quote Link to comment Share on other sites More sharing options...
LanceyDavid Posted December 16, 2010 Author Share Posted December 16, 2010 Thanks for the reply! I understand the sorting and such. What I don't egt it that they have each section seperated by date, and when the next day arrive it posts a huge date untop and then the videos for that day all appears underneath exactly on time, how do they do that? Instead of videos I am posting text underneath every date. I hope I explained it clearly. Thanks ahead of time Quote Link to comment Share on other sites More sharing options...
LanceyDavid Posted December 16, 2010 Author Share Posted December 16, 2010 Thanks for the reply! I understand the sorting and such. What I don't egt it that they have each section seperated by date, and when the next day arrive it posts a huge date untop and then the videos for that day all appears underneath exactly on time, how do they do that? Instead of videos I am posting text underneath every date. I hope I explained it clearly. Thanks ahead of time Quote Link to comment Share on other sites More sharing options...
LanceyDavid Posted December 17, 2010 Author Share Posted December 17, 2010 quick bump, really would like to solve this and see if anyone knows! THANKS!!! Quote Link to comment Share on other sites More sharing options...
PnzrDrgoon Posted December 17, 2010 Share Posted December 17, 2010 I would guess they do two queries. One to get the videos and their dates and one to get the comments associated with their videos. So there would be two tables that look like Table: videos Video_ID Video_File Date_Inserted Table: comments Comment_ID Video_ID Comment Date_inserted Then the code would look something like: $video_sql="SELECT Video_ID, Video_File, Date_Inserted FROM vidoes ORDER BY Date_Inserted DESC"; $video_query=mysql_query($video_sql); while($video_row=mysql_fetch_assoc($video_query)) { $video_id=$video_row['Video_ID']; $video=$video_row['Video']; $video_date=$video_row['Date_Inserted']; echo '<iframe>$video_row</iframe>'; //Get Comments $comment_sql="SELECT Comment FROM comments WHERE Video_ID = $video_id ORDER BY Date_Inserted"; $comment_query=mysql_query($comment_sql); while($comment_row = mysql_fetch_assoc($comment_query)) { echo $comment_row['Comment']; } } Quote Link to comment 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.