Jump to content

does anyone see why i would get double the amounts posted to the page?


mitchberry

Recommended Posts

So, i have a few different pages that correspond to each other.. 

 

it would take me a while to explain it, so i'll see if i can do so minimally while giving you enough info to go on..

 

when a person is logged in, it checks whether they are an admin or not. when they log in it takes them to a page that shows their sales and their commissions for those clients.

 

they can click on "my account" which uses a form and a hidden field and passes them to the page in question.    in this page, it gives them the ability to change their first and last name and their password... it also gives them a rundown of the totals of their numbers.

 

by the way "pounds" in this case is actually an industry term, but i use the GBP symbol because it makes sense. 

 

here's the problem.  when i am logged in as admin and i look at the overview page, it shows the numbers correctly..

 

when i log into the page in question as an admin AND OR when the employee logs in as a non admin to change their info,  a lot of the information has DOUBLED ... 

<?php
if ($_SESSION["contractor_login"] == "Admin" )
{ 
$result =	mysql_query("SELECT *, SUM(client_pounds), AVG(client_pounds), SUM(user_payment_left), COUNT(client_id) FROM contractors, whiteboard, lead_providers WHERE contractors.user_username = '".$user_username."' AND whiteboard.user_username = contractors.user_username");	
}

else
{
$result =	mysql_query("SELECT *, SUM(client_pounds), AVG(client_pounds), SUM(user_payment_left), COUNT(client_id) FROM contractors, whiteboard, lead_providers WHERE contractors.user_username = '".$access."' AND whiteboard.user_username = contractors.user_username");	
} ?>

anything that says SUM gives double the amount it should...  which is deals, total pounds and the commission.. 

 

which is not cool....

 

can anyone see why this would be the case?  i'm pretty sure it's not taking values from a previous page. the only thing it's taking from another page that i know of is the log in information in sessions... 

 

any thoughts are greatly appreciated.. if i need to provide code for associated pages i will.. 

 

below is the entire code..  thanks in advance

 

-------------------

<?php
include "head.php";
include "menu.php";

$_SESSION["contractor_login"]; // store session data
$_SESSION["contractor_password"];

$access= $_SESSION["contractor_login"];




if(isset($_SESSION['contractor_login']))
{
if(isset($_SESSION["contractor_password"]))
{



////////////////
if ($_SESSION["contractor_login"] == "Admin" )
{ 
$result =	mysql_query("SELECT *, SUM(client_pounds), AVG(client_pounds), SUM(user_payment_left), COUNT(client_id) FROM contractors, whiteboard, lead_providers WHERE contractors.user_username = '".$user_username."' AND whiteboard.user_username = contractors.user_username");	
}

else
{
$result =	mysql_query("SELECT *, SUM(client_pounds), AVG(client_pounds), SUM(user_payment_left), COUNT(client_id) FROM contractors, whiteboard, lead_providers WHERE contractors.user_username = '".$access."' AND whiteboard.user_username = contractors.user_username");	
}


?>

<?php
<form action="employee_update_script.php" method="post">


<?php echo "<span class=\"smallfont\">welcome: ".$_SESSION['contractor_login']. "</span>";


while($row = mysql_fetch_array( $result )) {








///things that appear and disappear if someone is or isn't an admin.... 
if ($_SESSION["contractor_login"] == "Admin" )
{ 

$EID = "<tr><td width=\"30px\"> </td>
<td width=\"100px\"><span class=\"smallfont\">EID</span></td>
<td><span class=\"smallfont\">".$row["emp_id"]."</span></td>
<td><input name=\"emp_id\" value=\"".$row["emp_id"]."\" type=\"text\" /></td></tr>"; 

$username = "<tr><td width=\"30px\"> </td> 
<td width=\"100px\"><span class=\"smallfont\">User</span></td>
<td><span class=\"smallfont\">".$row["user_username"]."</span></td>
<td><input name=\"user_username\" value=\"".$row["user_username"]."\" type=\"text\" /></td></tr>";

$commission = "<td width=\"100px\"><span class=\"smallfont\">Commission</span></td>
<td><span class=\"smallfont\">".$row["user_commission_rate"]."</span></td>
<td><select name=\"user_commission_rate\" id=\"user_commission_rate\">
  <option value=\"".$row["user_commission_rate"]."\">Select One...</option>
  <option value=\".1\">10</option>
  <option value=\".12\">12</option>
  <option value=\".15\">15</option>
  </select></td></tr>";

$old_leads = $row["user_leads"];

$leads = "<tr><td width=\"30px\"> </td> 
<td width=\"100px\"><span class=\"smallfont\">Total Leads</span></td>
<td><span class=\"smallfont\">".$row["user_leads"]." + </span></td>
<td><input name=\"new_leads\" type=\"text\" />
<input name=\"old_leads\" value=\"$old_leads\" type=\"hidden\" /></td></tr>";

$admin ="<tr><td width=\"30px\"> </td>
<td width=\"100px\"><span class=\"smallfont\">Admin Status</span></td>
<td><span class=\"smallfont\">".$row["user_isadmin"]."</span></td>
<td><select name=\"user_isadmin\" id=\"user_isadmin\">
  <option value=\"$user_isadmin\">Select One...</option>
  <option value=\"yes\">Allow</option>
  <option value=\"no\">Disallow</option>
  </select></td></tr>";



}

echo "
<br />
<br />
<input type=\"hidden\" name=\"user_username\" value=\"$user_username\"></td>

<table  class=\"table\" cellpadding=\"3px\" cellspacing=\"0\">";


echo "<tr align=\"center\" bgcolor=\"#006666\" >
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Employee ID</span></td>
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Deals</span></td>
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Total £</span></td>
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Avg £</span></td>
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Balance</span></td></tr>";

echo "<tr><td align=\"center\"><span class=\"smallfont\">".$row["emp_id"]."</span></td>";
echo "<td align=\"center\"><span class=\"smallfont\">".$row["COUNT(client_id)"]."</span></td>";
echo "<td align=\"center\"><span class=\"smallfont\">".$row["SUM(client_pounds)"]."</span></td>";
echo "<td align=\"center\"><span class=\"smallfont\">".$row["AVG(client_pounds)"]."</span></td>";
echo "<td align=\"center\"><span class=\"smallfont\">".$row["SUM(user_payment_left)"]."</span></td></tr>";


echo "</table><br />

<table  class=\"table\" cellpadding=\"3px\" cellspacing=\"0\">
<tr align=\"center\" bgcolor=\"#006666\" >
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Commission</span></td>
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Leads Given</span></td>
<td align=\"center\" width=\"80px\"><span class=\"smallwhitefont\">Admin</span></td>
<tr>
<tr>
<td align=\"center\"><span class=\"negativenum\">".$row["user_commission_rate"]."</span></td>
<td align=\"center\"><span class=\"negativenum\">".$row["user_leads"]."</span></td>
<td align=\"center\"><span class=\"negativenum\">".$row["user_isadmin"]."</span></td>
</tr>";

echo "</table><br />";

echo "<table width =\"900px\"> <tr><td><hr></td></tr></table>";
echo "<span class=\"smallfont\">CHANGE EMPLOYEE INFO</span>";
echo "<table border=\"0px\" cellpadding=\"3px\" cellspacing=\"0\">";

echo "$EID";
echo "$username";

echo "<tr><td width=\"30px\"> </td>"; 
echo "<td width=\"100px\" colspan=\"2\"><span class=\"smallfont\">Password</span></td>";
echo "<td><input name=\"user_password\" type=\"password\" value=\"".$row["user_password"]."\" type=\"text\" /></td></tr>";

echo "<tr><td width=\"30px\"> </td>"; 
echo "<td width=\"100px\"><span class=\"smallfont\">First</span></td>";
echo "<td><span class=\"smallfont\">".$row["user_first"]."</span></td>";
echo "<td><input name=\"user_first\" value=\"".$row["user_first"]."\" type=\"text\" /></td></tr>";

echo "<tr><td width=\"30px\"> </td>"; 
echo "<td width=\"100px\"><span class=\"smallfont\">Last</span></td>";
echo "<td><span class=\"smallfont\">".$row["user_last"]."</span></td>";
echo "<td><input name=\"user_last\" value=\"".$row["user_last"]."\" type=\"text\" /></td></tr>";

echo "<tr><td width=\"30px\"> </td>"; 

echo "$commission";
echo "$leads";
echo"$admin";




}///end while

echo "<tr><td width=\"30px\"> </td>"; 
echo "<td width=\"100px\"></td>";
echo "<td><span class=\"smallfont\"><input name=\"Submit\" type=\"submit\" value=\"Change\" /></span></td>";
echo "</table></form>";
?>     
    

 


<?php
}
}
else
{
echo"not logged in <a href=\"index.php\">login</a>";
}


include "footer.php";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

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.