This topic is locked

auto populate field

9/8/2010 5:00:07 PM
PHPRunner General questions
swant author

Is there any way lets say to have a number auto populate a field with a number start from 1- whatever and when a new month starts have it start from 1 again?

A
ann 9/9/2010

Hi,
you can do it for a field which is not a key field (it should be unique).

Fill this custom field in the Before record added event on the Events tab.

Here is a sample for MySQL:

if (date("j")!=1){

$sql="select max(customID) as mx from TableName where month(DateField)=month(Now()) order by mx";

$rs=CustomQuery($sql);

$data=db_fetch_array($rs);

$values["customID"]=$data["mx"]+1;

}

else{

$values["customID"]=1;

}