hi all...
i have a problem when my boss ask me to do something that i don't know how to do it..
i need the idea for increment ID that will count by date..
For example
today is 7/3/2012,user send request then id become AB-070312-1, user send other request at the day, then id become AB-070312-2 and so on...Tomorrow, user send request and id become AB-080312-1...
hurm..i have no idea about that..do have any idea? :?:

hope all of you have idea..

5 Years
Discussion Span
Last Post by HasNor

I can’t understand what could be the reason for such thing. Maybe not a good understanding of what a database is. Anyhow you know what the AB part of the id AB-080312-1 is , you also know how to produce the 080312 , ( date("dmy") ) , to get the last part just query count the id’s that start from AB-080312 (the previous logic) and add one to it.


thanks for reply..
actually AB is department, 080812 is current date, the last part is calling running number..that means how many request created from one department for a day..do get it? sorry i don't how to explain better..


try this

$rs_max=mysql_query("select max(id) as maxid from your_tbl_name where your_date_field=date(now()) and your_dept_field='$dept'");

Edited by karthik_ppts: n/a


Thanks for reply, i've try but not work..my code here..i have tried this but it just run the first statement event dept and date already exist.. is it my condition is problem?

			$dept = $row['dept'];
			$check="SELECT * FROM request WHERE date_request='$date_req' AND dept='$dept'";
			if (mysql_num_rows($rs) == 0) {  //if not exist
			$n='2'; //$n++ (increase if date and dept already exist)

erm..this actually something like count transaction for day by department and date..


Thank you Karthik_pranas for help..
actually yesterday i've study clearly how your given code's running, then i got it..
hurm..thank you very much..now i'm still in debung.. anyway TQVM.. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.