Appending Array in a loop with certain format
I am struggling to append data retreived from an SQL query in PHP. Basically I have this so far -

    $sql = "SELECT * FROM product WHERE productId = '1'";
    $result = mysql_query($sql);
    if(mysql_affected_rows() > 0){
         while($row = mysql_fetch_assoc($orderResult)){
               extract($row);
    	   $response["Sales"][]["Products"]["SaleProduct"] = array('ProductName'=>$ProductName);
         }
    }

This will work for the most part. It will append to each array, however where I am stumbling is if the SQL returns more than 1 row... 

Baically I am tryign to return an array in a web service, it will return "Sales" made. Each Sale could have many products in it. With the code I have so far it only caters for one product per sale. If 2 products are sold then it will essentially create 2 sales with 1 product each.

Can anyone guide me in the correct way to be able to get what I need?

Thanks
Appending Array in a loop with certain format
===

I am struggling to append data retreived from an SQL query in PHP. Basically I have this so far -

    $sql = "SELECT * FROM product WHERE productId = '1'";
    $result = mysql_query($sql);
    if(mysql_affected_rows() > 0){
         while($row = mysql_fetch_assoc($orderResult)){
               extract($row);
    	   $response["Sales"][]["Products"]["SaleProduct"] = array('ProductName'=>$ProductName);
         }
    }

This will work for the most part. It will append to each array, however where I am stumbling is if the SQL returns more than 1 row... 

Baically I am tryign to return an array in a web service, it will return "Sales" made. Each Sale could have many products in it. With the code I have so far it only caters for one product per sale. If 2 products are sold then it will essentially create 2 sales with 1 product each.

Can anyone guide me in the correct way to be able to get what I need?

Thanks