I have a table named disputes and in it I have id, reportid, statusid, datetoprint, dateprinted
This table holds all disputes and there will be different report id's and status id's. There will be a random number of disputes per reports so mysql code is like this;
SELECT COUNT(*) FROM disputes where reportid=10 and statusid=20
This number may be any number more than 3. Here is the math I need to run and then PHP / MySQL code to update database accordingly
Let's use 13 as our random number
With this COUNT I need to divide by 4 (25% of disputes) -This will be 3.25
Then if this is not a single digit number, I need to Round Down - To Change to 3
Then I need to set the DATETOPRINT for the first 3 records to CURDATE()
Next I need to next 3 records to have DATETOPRINT set to CURDATE() + 40 days
Next I need to next 3 records to have DATETOPRINT set to CURDATE() + 80 days
Next I need to next 3 records to have DATETOPRINT set to CURDATE() + 120 days
And the final records DATETOPRINT set to CURDATA() + 160 days
and so on.. My problem is that last part, how can I account for the single day, and account for the change in the start number. If the start number is 22;
With this COUNT I need to divide by 4 (25% of disputes) -This will be 5.5
Then if this is not a single digit number, I need to Round Down - To Change to 5
Then I need to set the DATETOPRINT for the first 5 records to CURDATE()
Next I need to next 5 records to have DATETOPRINT set to CURDATE() + 40 days
Next I need to next 5 records to have DATETOPRINT set to CURDATE() + 80 days
Next I need to next 5 records to have DATETOPRINT set to CURDATE() + 120 days
Next I need to next 5 records to have DATETOPRINT set to CURDATE() + 160 days
And the final 2 records DATETOPRINT set to CURDATA() + 200 days
Start Free Trial