Jump to content
MakeWebGames

Referal in HOF


gurpreet
 Share

Recommended Posts

OK so I'm tryna add referals in HOF. I got this from the Viewuser:

$rr=$db->query("SELECT * FROM referals WHERE refREFER={$r['userid']}");

 

I want to make it just like HOF level and stuff, but for referals.

 

$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 AND u.user_level != 2 $myf ORDER BY referals DESC,userid ASC LIMIT 20");

 

That doesn't work. I need it to get info from 2 tables but in 1 query...Help would be good :)

Link to comment
Share on other sites

Re: Referal in HOF

 

$refwin = mysql_query("SELECT * FROM referals WHERE refREFER={$r['userid']}");

 

{echo '$refwin';}

 

When I do that, it echos "$refwin" not the database info. Any ideas?

print "$refwin";

its still gona be the same lol

You need..

$refwin = mysql_num_rows(mysql_query("SELECT * FROM referals WHERE refREFER={$r['userid']}"));

Link to comment
Share on other sites

Re: Referal in HOF

Pog1:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/*******/public_html/competition.php on line 3

 

$refwin = mysql_num_rows(mysql_query("SELECT * FROM referals WHERE refREFER={$r['userid']}")); is line 3

Link to comment
Share on other sites

Re: Referal in HOF

 

$refwin = mysql_query("SELECT * FROM referals WHERE refREFER={$r['userid']}");

 

{echo '$refwin';}

 

When I do that, it echos "$refwin" not the database info. Any ideas?

print "$refwin";

its still gona be the same lol

You need..

$refwin = mysql_num_rows(mysql_query("SELECT * FROM referals WHERE refREFER={$r['userid']}"));

Lol, I didn't take a look at the code, and assumed he had it right, just glanced at the echo and noticed the single quotes :P

Link to comment
Share on other sites

Re: Referal in HOF

Doesn't print anything, here's my code so far, I know it shows the ranks by level, need to set that to rank by referals later. Reason there are so much errors is because I was tryin to code by myself, seems I'm not ready for this stuff yet.

<?php
include "globals.php";
$sql = sprintf("SELECT * FROM referals WHERE (refREFER = %u)", $r['userid']);
$query = mysql_query($sql) or die(mysql_error());
$refwin = mysql_num_rows($query);

echo '<h4>Competitions!</h4>

';

echo '<font size=5>MESSED UP ATM, SHOWING HIGHEST TO LOWEST LEVEL</font>';

print "$refwin";

echo '<h2>Current Competitions:</h2>
';
print "Referal competition.


<table width=75% cellspacing=1 class='table'> <tr> <td>[url='competition.php?action=referal']REFERALS[/url]</td></tr></table>";

switch($_GET['action'])
{
case "referal":
hof_ref();
break;
}

function hof_ref()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest number of referals.

<table width=75% cellspacing=1 class='table'><tr style='background:gray'> <th><font color=grey>Pos</font></th> <th><font color=grey>User</font></th> <th><font color=grey>Level</font></th></tr>"; 
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 AND u.user_level != 2 $myf ORDER BY level DESC,userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $userid) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> <td>$t{$r['level']}$et</td> </tr>";
}
print "</table>";
}

 

Special thanks to Dazza as he helped me with a lot of it.

Link to comment
Share on other sites

Re: Referal in HOF

 

$refwin = mysql_query("SELECT * FROM referals WHERE refREFER={$r['userid']}");

 

{echo '$refwin';}

 

When I do that, it echos "$refwin" not the database info. Any ideas?

print "$refwin";

its still gona be the same lol

You need..

$refwin = mysql_num_rows(mysql_query("SELECT * FROM referals WHERE refREFER={$r['userid']}"));

Lol, I didn't take a look at the code, and assumed he had it right, just glanced at the echo and noticed the single quotes :P

But in that case your still gonna try and print a query, not really gonna work.

Link to comment
Share on other sites

Re: Referal in HOF

Ok maybe if i post what i have so far, someone can help fill in the gaps?

 

<td>[url='halloffame.php?action=referals&filter={$filter}']REFERALS[/url]</td>

 

case "referals":
hof_referals();
break;

 

function hof_referals()
{
global $db,$ir,$c,$userid;
print "Showing the top 20 Referers

<table width=75% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> <th>Referals</th> </tr>";
$q=$db->query("SELECT * FROM referals ORDER BY refREFER DESC,refREFED ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['refREFER']} {$r['username']} [{$r['userid']}]$et</td> <td>$t".money_formatter($r['referals'],'')."$et</td> </tr>";
}
print "</table>";
}

 

It looks like this in the Hall Of Fame

Pos User Referals

1 4 [] 0

2 1 [] 0

So i have the users id's but no username showing and not showing how many referals???

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...