beast911 Posted October 18, 2007 Share Posted October 18, 2007 Hi, I am working on adding to my website, something that will show the view count for a video. Then I plan on showing the videos with the most views on my homepage. I know how to get mySQL datebase up and how to send info to and from it, but I don't know what the code for this would be. I have an id auto int. for the videos, but it's the code that counts the times the play button has been clicked that I am wondering about. Thanks in advance for the help. Quote Link to comment https://forums.phpfreaks.com/topic/73726-most-viewed-videos/ Share on other sites More sharing options...
Wes1890 Posted October 18, 2007 Share Posted October 18, 2007 What I do for my videos site is: Everytime the page for the video is loaded, it adds +1 to the video's total views. If you only want it to increase when the user has actually clicked PLAY then it will take more than php. And for displaying the top viewed vids just do: // Get the video data from the DB $sql = "SELECT * FROM video_table ORDER BY video_views ASC"; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($result); // Count how many rows (videos) there are selected. $total_vids = count($row); // Display each one for ($i=0; $i<$total_vids; $i++) { echo "{$i}. $row['video_title'] <br />"; } Be sure to change your table and column names. Quote Link to comment https://forums.phpfreaks.com/topic/73726-most-viewed-videos/#findComment-372023 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.