brown2005 Posted May 18, 2006 Share Posted May 18, 2006 Hi,I have a table called linksand i want to create a page where the links are ranked on the amount of times they have had hits...i.e.10000 hitsa.co.ukb.co.uk90000 hitsh.co.ukany help please? Quote Link to comment https://forums.phpfreaks.com/topic/9926-a-to-z-list/ Share on other sites More sharing options...
ober Posted May 18, 2006 Share Posted May 18, 2006 Are the hits stored in the same table?SELECT * FROM table XYZ order by hits Quote Link to comment https://forums.phpfreaks.com/topic/9926-a-to-z-list/#findComment-36892 Share on other sites More sharing options...
brown2005 Posted May 18, 2006 Author Share Posted May 18, 2006 sorry, yes they are in the same table as hits... Quote Link to comment https://forums.phpfreaks.com/topic/9926-a-to-z-list/#findComment-36897 Share on other sites More sharing options...
ober Posted May 18, 2006 Share Posted May 18, 2006 So is the question answered? Quote Link to comment https://forums.phpfreaks.com/topic/9926-a-to-z-list/#findComment-36932 Share on other sites More sharing options...
brown2005 Posted May 19, 2006 Author Share Posted May 19, 2006 No, sorry let me tell you again, i havnt explained it properly....instead of alfa.co.uk--------------------1000bravo.co.uk-----------------500charlie.co.uk----------------400cabbage.co.uk----------------400dikkins.co.uk----------------200i want them listed like;1000alfa.co.uk500bravo.co.uk400charlie.co.ukcabbage.co.uk200dikkins.co.uk Quote Link to comment https://forums.phpfreaks.com/topic/9926-a-to-z-list/#findComment-37093 Share on other sites More sharing options...
samshel Posted May 19, 2006 Share Posted May 19, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/9926-a-to-z-list/#findComment-37095 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.