<?php 
$db=$GLOBALS['db'];
$r=$db->query("select ou.document_no,op.id from ecmstockdocinsideouts as ou
join ecmstockoperations as op on op.parent_id=ou.id where op.parent_name is null");
while($dane=$db->fetchByAssoc($r)){
     echo "update ecmstockoperations set parent_name='".$dane['document_no']."' where id='".$dane['id']."';<br>";
}
?>