php - While loop doesn't outputs correct result -


i've been working on application has table named funds , funds table maintains incoming , outgoing of funds user account.

here's database design :-

name          type                       default     null recordid      int auto_increment                     no parentemail   varchar(255)                           no funds         int                                    no is_locked     varchar                    yes         no  

ok, suppose there 4 entries in table, 2 of them having status yes , 2 of them having no status, i'm using query sum , locked status table.

select sum(funds) funds,is_locked status funds parentemail = '" . $email . "' group is_locked 

and i'm using code put value of locked funds (funds status (is_locked) yes) , unlocked funds (funds status (is_locked) set no) different variables;

$query3="select sum(funds) funds,is_locked status funds parentemail = '" . $email . "' group is_locked"; $result3=mysql_query($query3,$db) or die (mysql_error($db)); $row3=mysql_fetch_array($result3); $ulfunds=0; $lfunds=0; while($row3=mysql_fetch_assoc($result3)) {     if($row3['status'] == "no") //if is_locked == no, funds not locked , stored in $ulfunds     {         $ulfunds=$ulfunds + $row3['funds'];     }     if($row3['status'] == "yes")//if is_locked == yes, funds are locked , stored in $lfunds     {         $lfunds=$lfunds + $row3['funds'];     } } 

problem

now if echo $lfunds(locked funds) , $ulfunds(unlocked funds), correct value $lfunds (locked funds, is_locked == yes) output 0 (the default value) $unfunds (unlocked funds).

how can fix should correct value in both variables?

thanks.

remove line code,

 $row3=mysql_fetch_array($result3); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -