Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old April 23rd, 2003, 10:20 PM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
list links in order of pop.

on my fantasy football site I have a <div> that holds 5 outside links. I pull these from my mysql table (more than 5 eventually.) How can I count the number of times each link is used and order it by most popular. I'm guessing by another field in db that increments. I'm just not sure how I will do that by having the person clicking a link to an outside site.

I know the SQL statement will be like:
"SELECT * FROM TABLE ORDER BY rank LIMIT 5;"

Thanks in advance

Reply With Quote
  #2  
Old April 23rd, 2003, 11:56 PM
sliver's Avatar
sliver sliver is offline
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 16 m 54 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: list links in order of pop.

Well have the links point to a page like out.php?page=http://somesite.com. And then on out.php have some sql like "update table set counter=counter+1 where url=$page". Also make sure counter isn't an auto_increment when you make your new field. Then when you show the links go "select * from table order by counter limit 5".

Reply With Quote
  #3  
Old April 24th, 2003, 02:29 AM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
RE: list links in order of pop.

if I have the links point to a page like out.php then will have to redirect the page to the outside link? I don't think I'm understanding how the "UPDATE..." query will run. The query its self is perfect though. Could you just explain the "bridge" page idea a little more for me.

Reply With Quote
  #4  
Old April 24th, 2003, 01:23 PM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: list links in order of pop.

Instead of linking directly to the site, you link to your page, which then redirects the user to the real site.
php Code:
Original - php Code
  1.  
  2. <?
  3. // out.php
  4.  
  5. mysql_query("UPDATE urls SET counter=counter+1 WHERE url="".$_GET["url"].""");
  6.  
  7. header("Location: ".stripslashes($_GET["url"]));
  8. ?>


php Code:
Original - php Code
  1.  
  2. <?
  3. // somepage.php
  4.  
  5. //...
  6.  
  7. $urls=mysql_query("SELECT * FROM urls ORDER BY counter DESC");
  8. while ($url=mysql_fetch_array($urls))
  9.     echo "<a href="out.php?url=".urlencode($url["url"])."">".$url["pagename"]."</a>";
  10.  
  11. //...
  12.  
  13. ?>

Reply With Quote
  #5  
Old April 24th, 2003, 01:26 PM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
RE: list links in order of pop.

I've never redirected a page before (kind of sad to admit). All I have to do is use header() to resend the header and change the page?

Reply With Quote
  #6  
Old April 24th, 2003, 01:28 PM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: list links in order of pop.

Yup, using header("Location: ...") is all you need to do. Make sure, though, to not output any content (echo, print, ...), otherwise it probably won't work...

Reply With Quote
  #7  
Old April 24th, 2003, 02:48 PM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
RE: list links in order of pop.

I don't want the user to leave index.php. Can I just repost the page to its self?

before click (index.php)
php Code:
Original - php Code
  1.  
  2. <?
  3. //db code up here
  4.  
  5. //link from the db
  6. echo "<a href="index.php?clicked=1&url=$url">$title</a>";
  7. ?>


after click (index.php)
php Code:
Original - php Code
  1.  
  2. <?
  3. if($_GET["clicked"] == 1) {
  4.    //db code up here
  5.  
  6.    //update the db
  7.    mysql_query("UPDATE urls SET counter=counter+1 WHERE url="".$_GET["url"].""");
  8.  
  9.    //resend the header
  10.    header("Location: ".stripslashes($_GET["url"]));
  11. }
  12. ?>


by the way, thank you for all your help guys!

Reply With Quote
  #8  
Old April 24th, 2003, 03:32 PM
ResNet9 ResNet9 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 101 ResNet9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to ResNet9
RE: list links in order of pop.

nevermind, on the last post. I want it to be opened on a new page so the way that you guys originally explained. Thanks

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > list links in order of pop.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway