View previous topic :: View next topic |
Author |
Message |
abyssisthebest -
Joined: 30 Jun 2005 Posts: 319 Location: Boston, UK
|
Posted: Tue May 30, 2006 10:54 am Post subject: Mysql and php (Order By) |
|
|
I have made my own referal script, that counts when somebody clicks on the link. I have also made a script that shows the top 5 referers.
Index - To show the top 5
Code: |
<?php
$query1 = "SELECT * FROM referer ORDER BY no DESC";
$run1 = mysql_query($query1) or die(mysql_error());;
$number = mysql_num_rows($run1);
if ($number==0){
echo "<center>We dont have any affiliates</center>";
}
$i=0;
$j=1;
$limit=5;
while ($i<$number){
$web_name = mysql_result($run1, $i, 'name');
$web_url = mysql_result($run1, $i, 'website');
$no = mysql_result($run1, $i, 'no');
echo $j .") <a href='http://".$web_url."' target='_blank'>".$web_name."</a> ($no)<br />";
$i++;
$j++;
};
?>
|
But I have had a bug reported that it actually shows
-------------------------
1) Compu-Geek (9)
2) Stevebart (3)
3) Insight PC's (3)
4) MrWiseOne.com (12)
--------------------------
When the number in brackets is the number of people refered. It only counts the first digit of the number. Does anybody know how to solve this? _________________ My online Portfolio |
|
Back to top |
|
 |
abyssisthebest -
Joined: 30 Jun 2005 Posts: 319 Location: Boston, UK
|
Posted: Tue May 30, 2006 11:36 am Post subject: |
|
|
I have got this problem sorted. Ill post how i did so it can help other people.
I logged in through phpmyadmin and selected the table and ran the query:
Code: | SELECT * FROM referer ORDER BY `no` DESC |
I then noticed that it gave the sane result as the form, so it coudnt be my code, it had to be something in the table.
I then thought could it be because the column type was VARCHAR, so i changed it to TINYINT.
It now works :D _________________ My online Portfolio |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|