Skippy
03-08-2010, 07:54 PM
Hey, I'm looking for a bit of help on the project I'm working on.
This is my database structure 'users':
http://www.wowimages.net/files/95unr1e3don9gc60bbu7.jpg
<?php
$offerUid = mysql_real_escape_string($_GET['coid']);
$result = mysql_query("SELECT * FROM pending WHERE id='$offerUid'");
$data = mysql_fetch_array($result);
$value = $data['amount'];
$offer = $data['offerID'];
$userid = $data['userID'];
$user2 = $data['username'];
$bresult = mysql_query("SELECT * FROM users WHERE id='$userid'");
$getui = mysql_fetch_array($bresult);
$balance = $getui['complete'];
$pending = $getui['pending'];
$newbalance = $balance + $value;
$newpending = $pending - $value;
mysql_query("UPDATE users SET complete='$newbalance' WHERE id='$userid'");
mysql_query("UPDATE pending SET status='1' WHERE id='$offerUid'");
mysql_query("UPDATE users SET pending='$newpending' WHERE id='$userid'");
echo "The offer has been confirmed and the user has been credited.";
?>
The code above takes the value of an item in 'pending' and puts it the `complete` field in users.
I would like it so that when `complete` goes over 1.00 it will then get the id of the user it was referred by from `refer` and put a 1 in their `completereferrals`.
eg. User1 refers User2. User1's id is then placed in User2's refer field. User2's complete field goes over 1.00. 1 is then added to User1's complete refer field.
Can anyone help me out with this please?
Thanks.
This is my database structure 'users':
http://www.wowimages.net/files/95unr1e3don9gc60bbu7.jpg
<?php
$offerUid = mysql_real_escape_string($_GET['coid']);
$result = mysql_query("SELECT * FROM pending WHERE id='$offerUid'");
$data = mysql_fetch_array($result);
$value = $data['amount'];
$offer = $data['offerID'];
$userid = $data['userID'];
$user2 = $data['username'];
$bresult = mysql_query("SELECT * FROM users WHERE id='$userid'");
$getui = mysql_fetch_array($bresult);
$balance = $getui['complete'];
$pending = $getui['pending'];
$newbalance = $balance + $value;
$newpending = $pending - $value;
mysql_query("UPDATE users SET complete='$newbalance' WHERE id='$userid'");
mysql_query("UPDATE pending SET status='1' WHERE id='$offerUid'");
mysql_query("UPDATE users SET pending='$newpending' WHERE id='$userid'");
echo "The offer has been confirmed and the user has been credited.";
?>
The code above takes the value of an item in 'pending' and puts it the `complete` field in users.
I would like it so that when `complete` goes over 1.00 it will then get the id of the user it was referred by from `refer` and put a 1 in their `completereferrals`.
eg. User1 refers User2. User1's id is then placed in User2's refer field. User2's complete field goes over 1.00. 1 is then added to User1's complete refer field.
Can anyone help me out with this please?
Thanks.