0

I am trying to create a referral list/table in php so that every member can see who they referred. Only 2 columns to display are: name and email.

This code counts each members' personal referrals just fine. I'm showing it to you to see if I can branch off from it or not

<?
}
}

function middle()
{
include "config.php";
$id=$_SESSION['username_session'];
$rs = mysql_query("select * from users where Username='$id'");
$arr=mysql_fetch_array($rs);
$email=$arr[7];
$username=$arr[8];
$password=$arr[9];
    $name=$arr[1];


?>

As of today, you have <b><font size="3"><?
$rs1=mysql_query("select * from users where ref_by='$username'");
echo mysql_num_rows($rs1);?></b></font> personal referrals.</font>

This is the code I am having trouble with in creating a table/list of personal referrals per member. LIke I said above, this code calls all members in the system which is not what I want. I only want personal referrals per member. Maybe this code can be edited differently to work, or use the above code to make it work. Im not sure.. so any help help is much appreciated. thanks

<?
 include "./membersrecords.php";
 include "./config.php";

$user=$_SESSION['username_session'];
$rs2 = mysql_query("select * from users where Username='$user'");
$arr2=mysql_fetch_array($rs2);
$email2=$arr[7];
$username2=$arr[8];
$password2=$arr[9];
    $name2=$arr[1];

echo("<table border=0 width='100%' cellpadding=0 cellspacing=0>");
echo("<tr><td align=left valign=top><br>");

$sql = "select * from users where active=1";
$result = mysql_query($sql);
$rs3  =  mysql_fetch_row($result);
$sql1 = "select * from users where active=0";
$result1 = mysql_query($sql1);
$rs4  =  mysql_fetch_row($result1);

echo("<hr>");
echo("</td></tr><tr>");
echo("<td align=left valign=top>");


$b=$_GET[b];
if(!$b) $b=$_POST[b];
$p=$_GET[p];
$id=$_POST[id];

$list="select * from users where ref_by='$username2' order by ID";
membersrecords($list,1,$u,$pa,$b,$p);

?>
  • 1
    Please don't use PHP short open tags. – Jason McCreary Jul 10 '13 at 20:51
  • thats not the issue,, if you can help with my code above that'll be great,, thanks – Aaron Soares Jul 10 '13 at 20:59
  • 2
    and don't use the depreciated mysql_* –  Jul 10 '13 at 21:01
  • you have `$arr2=mysql_fetch_array($rs2); ... $username2=$arr[8];` in your second code. You need to change the username to `$username2=$arr2[8];` as well as all other to `$arr2[]` – Sean Jul 10 '13 at 21:05
  • 3
    That code's a mess. using unquoted array keys everywhere, deprecated DB libraries, probably SQL injection vulnerabilities... – Marc B Jul 10 '13 at 21:07
  • The only one that is helping is Sean. Everyone else is telling what not to use and how big of a mess it is instead of telling me what needs to be fixed. That is why I came here seeking help. If I was a PHP genius I wouldnt be asking for help. So let's try this again guys.. I am seeking helping, if there is something that you see is wrong please tell me how to correct with possible codes.. thanks – Aaron Soares Jul 10 '13 at 21:24
  • 1
    @Aaron Soares, that's where you're wrong. We **are** helping you and telling you what **needs** to be fixed. – Jason McCreary Jul 10 '13 at 21:33
  • well then don't post on a *public* site, if you don't want *public* comments. –  Jul 10 '13 at 21:35
  • Yea but I dont how to fix it by just telling me what is only wrong without possible codes. I know my code is wrong because its not working the way I want it. Im looking for solutions – Aaron Soares Jul 10 '13 at 21:36
  • google "short open tags"; google "depreciated mysql_*"; google " unquoted array keys"; google "SQL injection vulnerabilities." –  Jul 10 '13 at 21:43

0 Answers0