![]() |
Sergey Kornilov admin 10/15/2010 |
The best approach is to rely on your database in order to generate the next number using Autonumber or Autoincrement field. Try to do so in your code is not a reliable way. |
T
|
tedwilder 10/17/2010 |
Hello Serjey, Ann, I have studentmaster table with studentid column primary key studentid, it is a required field. I tried all the codes in before record added, after record added as given in the forum everywhere, but I am not able to populate the next value of studentid in the studentid column while entering the record. I want to see that value when i say inline add record, or add record. Please please help and put the code here so that i will try my level best to do so. Thank you in advance. Arunabh
|
A
|
arunabh author 10/26/2010 |
Thanks Ted, admin is right but sometimes you just can't use simple incremential like for bill numbers. I do in BEFORE DISPLAY event for ADD PAGE: $sql="select max(substr(PURCHASE_NUMBER,9)) as mx from TABLENAME where substr(PURCHASE_NUMBER,7,2)=month(now()) order by mx"; $rs=CustomQuery($sql); $data=db_fetch_array($rs); $str="SO"; $str2=date("Ym"); $str3=($data["mx"]+1); $_SESSION["PURCHASE_NUMBER"]="$str$str2".str_pad($str3, 5, 0, STR_PAD_LEFT); in this example it creates a new number based on the last one that it founds in database. It's very effective . it's a number like SO20100901 ( year,month,number that increase , at the end of the month it starts at 1 ). Of course you can modify it to your need. Don't forget to put in editor as defautl values " $_SESSION["PURCHASE_NUMBER"] " otherwise it won't print it on the add page. This way i have a new number each time i go on " add record" and that number is related to the last record on the database. |