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

       
                                                  <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>
  

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.

thanks i have been able to solve it.