My intention is to track duplicate entryes of records sellings and merge the quantities in one, and delete the other. Eg:
1, Record Blue , 9
2, Record Blue , 10
3, Record Red , 3
Should be like this:
1, Record Blue, 19
3, Record Red, 3
using this code, it appears that all the records are selected when they have estado = 1. In the second loop, called “ordenes2”, some of those records are set estado = 0, so, they should not be selected when the first recordset reaches them in the table, but they do.
$sql="select * from records where estado =1 order by id desc ";
$rsproc=mysql_query($sql);
while($ordenes = mysql_fetch_array($rsproc, MYSQL_ASSOC)){
$sqlh="select * from records where estado =1 and id <> " , $ordenes[id];
$rsproc2=mysql_query($sql);
while($ordenes2 = mysql_fetch_array($rsproc2, MYSQL_ASSOC)){
// some work, etc...
$sql="update records set estado= 0 where id= ". $ordenes2[id];
}
}