Jump to content


Photo

a to z list


  • Please log in to reply
5 replies to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 18 May 2006 - 02:15 PM

Hi,

I have a table called links

and i want to create a page where the links are ranked on the amount of times they have had hits...


i.e.


10000 hits

a.co.uk
b.co.uk

90000 hits

h.co.uk

any help please?

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 18 May 2006 - 02:22 PM

Are the hits stored in the same table?

SELECT * FROM table XYZ order by hits

Info: PHP Manual


#3 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 18 May 2006 - 02:28 PM

sorry, yes they are in the same table as hits...

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 18 May 2006 - 05:26 PM

So is the question answered?

Info: PHP Manual


#5 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 19 May 2006 - 07:38 AM

No, sorry let me tell you again, i havnt explained it properly....

instead of

alfa.co.uk--------------------1000
bravo.co.uk-----------------500
charlie.co.uk----------------400
cabbage.co.uk----------------400
dikkins.co.uk----------------200

i want them listed like;

1000
alfa.co.uk

500
bravo.co.uk

400
charlie.co.uk
cabbage.co.uk

200
dikkins.co.uk

#6 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 19 May 2006 - 07:56 AM

I guess if you are talking of displaying , then it can be done with code on the front end. Something like this

<?php 
//make db connection here

$query = "SELECT * FROM table XYZ order by hits desc";
$result = mysql_query($query) or die (mysql_error());
$num = mysql_num_rows($result);
$current_price = 0;
for($i=0;$i<$num;$i++) {
    $row = mysql_fetch_array($result);
    if($row['hits'] != $current_price) {
    echo $row['hits']."<br>";
    $current_price = $row['hits'];
    }
    echo $row['url']."<br>";
}
?>

I have not tested this code, but should work.

hth


Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users