Jump to content

Archived

This topic is now archived and is closed to further replies.

brown2005

a to z list

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Are the hits stored in the same table?

SELECT * FROM table XYZ order by hits

Share this post


Link to post
Share on other sites
So is the question answered?

Share this post


Link to post
Share on other sites
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

Share this post


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

[code]
<?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>";
}
?>
[/code]

I have not tested this code, but should work.

hth

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.