Jump to content
Larry Ullman's Book Forums

Recommended Posts

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 :mellow:

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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
  • Upvote 2

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...