Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2009
    Posts
    68
    Thanks
    1
    Thanked 1 Time in 1 Post

    PHP update help.

    I'm looking for some help with my site.

    This is the code I have so far.

    PHP Code:
    <?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.

  • #2
    New Coder
    Join Date
    Feb 2010
    Posts
    29
    Thanks
    0
    Thanked 3 Times in 3 Posts
    C'mon, try to write this code, it is not that hard
    We will help you with errors , if you encounter any.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •