SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    update needs to refreshed before displaying

    please i am updating a data in the table outstanding, but the page needs to be refreshed before it displays the update for $row['obal'] , any help or clue

    PHP Code:
                                                      <tr>
        <th>TO BALANCE</th>
        <th><?php
                    
        $tobal 
    = ($totalprice-$partpayment);
        
        
        echo 
    $tobal;
        if (
    $tobal!=0)
        {  
        
            
    $pplresult mysql_query("SELECT * FROM outstanding WHERE Uname = '{$_SESSION['username']}'") or die(mysql_error());
                      
    $row mysql_fetch_assoc($pplresult); 
       
     
    $query mysql_query("
    UPDATE outstanding 
        SET outstandingbal = '
    $tobal'
                WHERE outstandingbal='
    {$row['outstandingbal']}'
            AND 
                Uname = '
    {$_SESSION['username']}'
     "
    ) or die(mysql_error());
    }
         
    ?></th>                
               </tr>
      [B]                                 <tr>
        <th>OUTSTANDING</th>
        <th><?php
        $pplresult 
    mysql_query("SELECT * FROM outstanding WHERE Uname = '{$_SESSION['username']}'") or die(mysql_error());
      
    $row mysql_fetch_assoc($pplresult); 
        
    //echo $obal;
       // echo $row['obal'];
    if($totalprice==0){
     
    $queryreg mysql_query("
    UPDATE outstanding 
        SET obal = '
    {$row['outstandingbal']}
                WHERE obal='
    {$row['obal']}
            AND 
                Uname = '
    {$_SESSION['username']}'
     "
    ) or die(mysql_error());
     echo 
    $row['obal'];  }
    else{
     echo 
    $row['obal'];
     }
      
    ?></th>                
               </tr>[/B]
                                <tr>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    88
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I would make this easier to understand by separating the sql stuff from the display of the results. No need to intermingle this stuff.

    As for your update query it looks flawed. Why are you selecting the record using where outstanding bal=..... when your first query only selected based upon the user name?

    What problem are you having anyway? You didn't say, you just asked for help.

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thanks i have been able to solve it.


Bookmarks

Posting Permissions

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