1
您好我曾使用過這個下面的代碼如何使我的ID從12-09CB1到12-09CB0001自動增量?
$last_id=mysql_query("select * from complaint_list order by complaint_id Desc Limit 1");
$complaint_last=mysql_fetch_array($last_id);
$complaintid=$complaint_last['complaint_id'];
$complaintid = str_pad($id, 4, '0');
$year = substr($get[0],2,2);
$complaint_number=$year."-".$get[1]."CB".$complaintid;
mysql_query("insert into complaint_list(complaint_number, sap_number, complaint_type, circle_id) values('" . $complaint_number . "','" . $_POST['sap_number'] . "', 'DU', " . $_POST['circle'].")");
它顯示爲12-09CB0000所有的時間。
請幫我
你還需要現在叫'str_pad'你是填充在MySQL? – Barmar