Displaying and Gathering lists

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jonsta
Forum Newbie
Posts: 3
Joined: Mon Mar 02, 2009 11:56 am

Displaying and Gathering lists

Post by Jonsta »

Hi i am starting a site and would like to have a most popular pages list on everypage visited which is why i cannot do it on HTML.

I would like it to display the top 20 pages (either by hits, preferably on a time basis), or user rating (stars). I have listed the things i think i need the php code to do.

The things i think it needs to do are:
  • :arrow: gather the amount of hits/star rating from every page.
    :arrow: sort the values into the numerical order where the highest is top.
    :arrow: list the first 20.

If you could help me find a way t do this would be extremely greatful so please even if it may only help abit or if it is stating the obvious(i really am a noob to php), i would really appreciate them.
User avatar
highjo
Forum Contributor
Posts: 118
Joined: Tue Oct 24, 2006 1:07 pm

Re: Displaying and Gathering lists

Post by highjo »

i think there are lot tutorial out there about what you are talking about.i think you should google it.it's easy and i'm sure you will find one.gud luck.
Jonsta
Forum Newbie
Posts: 3
Joined: Mon Mar 02, 2009 11:56 am

Re: Displaying and Gathering lists

Post by Jonsta »

i wish it was that simple but i cant seem to find one. if you google it and find anything i will be in your debt if you post it here and its good. maybe im searching the worng things so if you know the best words to search or some good website links please post them here.
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: Displaying and Gathering lists

Post by mickeyunderscore »

The easiest way I can think of to do this would be to utilize a MySQL database. Create a table called 'pages' with the fields: page_id, page_name, page_hits, page_rating. Then just update them as you need (e.g. increment page_hits when a user enters that particular page).

You will find it a lot easier to sort data when you do it from a database, as you can have the database sort it for you.

You need to learn how to create a MySQL database, how to connect to a database in PHP and how to write MySQL queries. Entering those phrases into google should give you some results/tutorials.
Jonsta
Forum Newbie
Posts: 3
Joined: Mon Mar 02, 2009 11:56 am

Re: Displaying and Gathering lists

Post by Jonsta »

mickeyunderscore wrote:The easiest way I can think of to do this would be to utilize a MySQL database. Create a table called 'pages' with the fields: page_id, page_name, page_hits, page_rating. Then just update them as you need (e.g. increment page_hits when a user enters that particular page).

You will find it a lot easier to sort data when you do it from a database, as you can have the database sort it for you.

You need to learn how to create a MySQL database, how to connect to a database in PHP and how to write MySQL queries. Entering those phrases into google should give you some results/tutorials.
Thanks this has been really helpful. i ahve no problem learning mySQL and how to connect as i am currently using a beginners tutorial which covers many aspects of php including mySQL. Thanks for the advice. I currently no basically nothing about mySQL though although i do have it downloaded (i got an all in one package, very helpful :D ). i do know abit about databases though.

so i need to have the hit counter and user rating directly connected to mySQL. I think ill be alright for now so thanks again btw, feel free to correct me about anything ive done worng or to go into more detail in your post. Best regards, Jonsta
Post Reply