<?
$w=mysql_query("select ecminvoiceoutitems.*,ecminvoiceouts.document_no from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceouts.id=ecminvoiceoutitems.ecminvoiceout_id where ecminvoiceouts.register_date like '2009-11-%' and ecminvoiceoutitems.code like 'RE00282' and ecminvoiceouts.deleted='0' and ecminvoiceoutitems.deleted='0' and ecminvoiceouts.type!='correct'");
while($r=mysql_fetch_array($w)){
	echo $r['document_no']." ".$r['price']." ".$r['quantity']." ".$r['total']." ".$t."<br>";
	$t+=$r['price']*$r['quantity'];
	$q+=$r['quantity'];
	$i++;
}
echo $t." ".$q." ".$i;
?>