Jump to content

Update help.


AppleThreat

Recommended Posts

I'm looking for some help with my site.

 

This is the code I have so far.

 

<?php
session_start();
require ("../connect.php");
require("../functions.php");
require("functions.php");
include("template/header.php");
?>

   <div id="content" align="center">
   
<?php
if($_SESSION['status'] != 2){
   doredirect("index.php");
}
if($_SESSION['status'] == 2){
   $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.";
   
}
?>

   </div>
   
<?php
include("template/footer.php");
?>

 

This code takes the value of a field in the database and adds it to a field in the table 'users' called complete. It then take away that value from a field called 'pending'.

 

I would like it so that when the field called complete in 'users' has the value equal or the same as 1.00 it will check 'users' for their user id in a field called 'refer' and add a 1 to the field called 'complete referrals'.

 

Eg. If a user called 'Bob' refers a user called 'Alan', it will update the field called refer in 'Alans' table with 'Bobs' user id. If 'Alan' has the value equal or the same as 1.00 in a field called complete, it will then update a field called completereferrals in 'Bobs' table with the number 1.

 

Can anyone help me with this please?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/193708-update-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.