Me again,
In this case I have an accountingcode table [ACCOUNTINGCODE] with the fields:
ACC1CUST (example: IVMA)
ACC2DATE (example: 12)
ACC3NROFPROJ (example: 05)
ACC4USER (example: JD)
Let me explain.
These is the example of an accountingcode:
IVMA-12-01-JD
IVMA-12-02-RP
IVMA-12-03-WD
IVMA-12-04-JD
ACC1CUST is filled with a NAMECODE of a [CUSTOMER].
ACC2DATE are the 2 end numbers of the year the [ACCOUNTINGCOE] is made by the user.
ACC3NROFPROJ is the number of projects of the same [CUSTOMER] in the same year. So ACC1CUST, ACC2DATE and ACC3NROFPROJ depend on each other.
ACC4USER is the NAMECODE of the [EXECUTOR] so this is not so important here.
I made a generator query. This generator counts +1 on the MAX projects which he has in the [ACCOUNTINGCODE]. But my code isn’t depending on the the year (ACC2DATE). So if I already have IVMA-12-01-JD and next I place IVMA-13 it won’t start over at 01, but continues at 02. Ofcourse, because my code is checking the amount of projects of the ACC1CUST.
My query is:
$projectcount="
SELECT accountingcode.custid, customer.custid, MAX(acc3nrofproj) as 'projects'
FROM accountingcode, customer
WHERE accountingcode.custid= customer.custid
AND customer.custid = '$custid'
";
$result3=mysql_query($projectcount) or die("query fout " . mysql_error() );
while( $record3=mysql_fetch_array($result3) )
{
$projectcount=$record3['projects'];
$projectcount = $projectcount+1;
$format = '%1$03s';
$formatprojectcount = sprintf($format, $projectcount);
}
But this doesn’t make any difference if you start a new year which doesn’t exists already in ACC2DATE.
Anyone any idea how I can make this work?
Thank you alot in advance!
FOUND IT
$projectcount="
SELECT accountingcode.custid, accountingcode.acc2date, MAX(acc3nrofproj) as 'projects'
FROM accountingcode, customer
WHERE accountingcode.custid= customer.custid
AND customer.custid = '$custid'
AND acc2date = '$formatdatefrom'
";
$result3=mysql_query($projectcount) or die("query fout " . mysql_error() );
while( $record3=mysql_fetch_array($result3) )
{
$projectcount=$record3['projects'];
$projectcount = $projectcount+1;
$format = '%1$03s';
$formatprojectcount = sprintf($format, $projectcount);
}
Use the above query in a for loop starting from a baseYear to the final year.