Show most visited links

This is a discussion on "Show most visited links" within the PHP Forum section. This forum, and the thread "Show most visited links are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 28th, 2007, 14:32
New Member
Join Date: Dec 2006
Location: Sweden
Age: 54
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Show most visited links

I have a webpage with links which I wish to make a top ten-list of so I need a script that will do the job for me

If anyone have a tip how to do this it would be of great help. Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 28th, 2007, 15:33
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

i think that this would require you to add to a mysql record every time i page is loaded.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 28th, 2007, 15:33
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

do you know how to create mysql tables?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Aug 28th, 2007, 17:03
New Member
Join Date: Dec 2006
Location: Sweden
Age: 54
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

Thanks for reply!
I have a database but I don't know how to make a table in it.
I only have permission to one database.

I found a script called GoLinks but I get stuck when it comes to create a table in my database.
GoLinks seems good but I don't need all of the stuff that comes with it

Last edited by berraf; Aug 28th, 2007 at 17:20.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Aug 28th, 2007, 17:43
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

Do you know if your server has phpMyAdmin installed?

That is the easiest way to work with MySQL databases. It does all the work for you

otherwise your going to have to learn some SQL, you can learn through some of these sites.

http://www.w3schools.com/sql/default.asp
http://sqlcourse.com
http://www.sql-tutorial.net
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Aug 28th, 2007, 18:04
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

make a database called web (or something) and I can make a quick code for you
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Aug 28th, 2007, 19:43
New Member
Join Date: Dec 2006
Location: Sweden
Age: 54
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

Quote:
Originally Posted by alexgeek View Post
make a database called web (or something) and I can make a quick code for you
Okey, I've made the database and would really appreciate the code from you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Aug 28th, 2007, 20:33
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

alright then,
5 mins.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Aug 28th, 2007, 20:38
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

save this as createtable.php then run it, if you get errors tell me.
PHP: Select all

<?php
mysql_connect 
('localhost''put_username_here''put_password_here') ;
mysql_select_db ('web');

$sql "create table users (pagename varchar (255), hits int (20) default '0');";
mysql_query($sql) or die(mysql_error());
echo 
"table made";
?>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Aug 29th, 2007, 05:50
New Member
Join Date: Dec 2006
Location: Sweden
Age: 54
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

The script works like a clock! Thanks!

How can I go on from here?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Aug 29th, 2007, 06:01
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

Okay, I've been up all night.
not slept
I'm off to bed, and I'll do the rest for you in a few hours
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Aug 29th, 2007, 23:49
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

Well I won't actually write the script for you. We encourage learning by yourself here

I can however give you some pointers though

I'd have a table with these fields: id|url|hits

Then the link on the page would be something like this "outgoing.php?id=1"

Then the outgoing.php script would extract the url from the database with the matching id as the one in ?id=x

If a match is found you then update hits to add one on.

If all go well you then redirect to the url (using header() function) which you have just pulled out of the database.

This may not be the best way of doing it but it will work.

Hope this will help ya out,

Blake
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Aug 29th, 2007, 23:54
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

Quote:
Originally Posted by Blake121 View Post
Well I won't actually write the script for you. We encourage learning by yourself here

I can however give you some pointers though

I'd have a table with these fields: id|url|hits

Then the link on the page would be something like this "outgoing.php?id=1"

Then the outgoing.php script would extract the url from the database with the matching id as the one in ?id=x

If a match is found you then update hits to add one on.

If all go well you then redirect to the url (using header() function) which you have just pulled out of the database.

This may not be the best way of doing it but it will work.

Hope this will help ya out,

Blake
or instead of headers and stuff.
you could just include a script on every page you want ranked,
and that script would add one to the table.
a lot easier
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Aug 30th, 2007, 00:12
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

Yeah but what's the script gonna do? hows it gonna know what link you clicked and which one to add a hit onto?

Unless you used AJAX. But that's probably more bother than it's worth lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Aug 30th, 2007, 00:29
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

you don't have to know which link you clicked
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Aug 30th, 2007, 00:30
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

Why not? There's a big list of them on the page.

You'll need to know which url it is in question

Did you look at the link they posted lol

Last edited by Blake121; Aug 30th, 2007 at 00:34.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Aug 30th, 2007, 01:49
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Show most visited links

but if you put the script on every page, it will put itself in the database,
using $_SERVER['REQUEST_URI']
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #18  
Old Aug 30th, 2007, 06:32
New Member
Join Date: Dec 2006
Location: Sweden
Age: 54
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Show most visited links

Well I'm a total newbie so it would take me to much time to learn to do this script so it would be great if I could get that help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #19  
Old Aug 30th, 2007, 06:43
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts