wushu Posted February 13, 2014 Share Posted February 13, 2014 hey everybody, i have a request here,i'm a newbie in which called php and mysql.. i have finished the HTML of my website and now i want to implement a sidebar for Most Popular Posts.. i'masking if u can afford me with a tutorial from the scratch to build my sidebar? plz? thanks in advance Link to comment Share on other sites More sharing options...
HartleySan Posted February 13, 2014 Share Posted February 13, 2014 Hello, and welcome to the forums. I don't know if anyone is going to just give you all the code, but we can help point you in the right direction. To start with, are you keeping track of how many times a post is viewed in the DB? Link to comment Share on other sites More sharing options...
Antonio Conte Posted February 13, 2014 Share Posted February 13, 2014 You need to follow these steps to implements such functionality: 1. Keep track of views. This can be saved in your post/article/etc table along with other info, or in a separate table with a foreign key to the article ID. Each time an article is loaded using PHP, simply update the views column in the table. (You might also use flat-files, the principle is the same) 2. Query for articles based on views. The basic query looks something like this: SELECT * FROM articles ORDER BY views DESC LIMIT 10 2 Link to comment Share on other sites More sharing options...
wushu Posted February 14, 2014 Author Share Posted February 14, 2014 You need to follow these steps to implements such functionality: 1. Keep track of views. This can be saved in your post/article/etc table along with other info, or in a separate table with a foreign key to the article ID. Each time an article is loaded using PHP, simply update the views column in the table. (You might also use flat-files, the principle is the same) 2. Query for articles based on views. The basic query looks something like this: SELECT * FROM articles ORDER BY views DESC LIMIT 10 i understand a bit what is a database and what is a table, the Query u gave me is exactly what i 'm using, the problem that bothers me is the php code.. i mean how to connect between the HTML and MySQL thanks alot for helping Link to comment Share on other sites More sharing options...
HartleySan Posted February 14, 2014 Share Posted February 14, 2014 You need to use the MySQLi family of functions that are built into PHP. For any further questions, I highly recommend purchasing Larry's PHP & MySQL book. Everything is very simply and clearly explained there. Link to comment Share on other sites More sharing options...
wushu Posted February 15, 2014 Author Share Posted February 15, 2014 HartlySan, thank u for the help and indeed i'm gonna buy that book for sure:) Link to comment Share on other sites More sharing options...
Recommended Posts