I want to modify the code below to generate the profile id in yymmdd0001

The code below generates a profile id in the form yyyymmdd01, we want to modify it to generate the profile id in th e form yymmdd00001. Any help will be appreciated.

------------------------Code begins below this line -----------------

function generateid() 
{
	$selectregcount=mysql_fetch_array(mysql_query("SELECT * FROM mlm_reg_count WHERE reg_id=1"));
	$renewdate=explode("-",$selectregcount['reg_date']);
	$currmonth=date("m");
	$currentyear=date("y");
	 $curdate=date("d");
	
	if(($renewdate[0]<$currentyear) || ($renewdate[1]<$currmonth)|| ($renewdate[2]<$curdate)) {
		$updateregcount=mysql_query("UPDATE mlm_reg_count SET reg_count=1, reg_date=NOW() WHERE reg_id=1");
		return $currentyear.$currmonth.$curdate."01";
	} else {
		$currentcount=$selectregcount['reg_count']+1;
		$updateregcount=mysql_query("UPDATE mlm_reg_count SET reg_count=$currentcount WHERE reg_id=1");
		if($selectregcount['reg_count']<=9)
		{
			return $renewdate[0].$renewdate[1].$renewdate[2]."0".$currentcount;
		}
		else
		{
		 	return $renewdate[0].$renewdate[1].$renewdate[2].$currentcount;
		}
	}
}

----------code ends above this line--------------------------

Thank you!

hi we sorted it out

When your still using dangerous, obsolete code you haven’t figured anything out. You need to use PDO. https://phpdelusions.net/pdo

As @benanamen said, you need to get rid of the no-longer-supported mysql_ calls, and use a more modern and secure method of accessing the database.

As you only seem to use the reg_date column in your initial query, it would also be good practice to only retrieve that column, rather than using select * as you do.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.