Jump to content

Sort By date


LanceyDavid

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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'];
     }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.