Page 1 of 1
Displaying and Gathering lists
Posted: Mon Mar 02, 2009 12:03 pm
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:
gather the amount of hits/star rating from every page.
sort the values into the numerical order where the highest is top.
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.
Re: Displaying and Gathering lists
Posted: Mon Mar 02, 2009 12:12 pm
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.
Re: Displaying and Gathering lists
Posted: Mon Mar 02, 2009 12:59 pm
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.
Re: Displaying and Gathering lists
Posted: Mon Mar 02, 2009 1:44 pm
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.
Re: Displaying and Gathering lists
Posted: Mon Mar 02, 2009 3:46 pm
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

). 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