[英]how to save number as 0001 or 0006 in php, mysql database?
i am fetching database value of a column as 0005 , then i am adding 1 to it and save it in the database with a char ABHI but in the database its saved as ABHI6 not ABHI0006. 我正在获取一列的数据库值作为0005,然后向其添加1并使用char ABHI将其保存在数据库中,但在数据库中将其另存为ABHI6而不是ABHI0006。 how to do it??
怎么做??
here is the php script 这是PHP脚本
$name = mysqli_real_escape_string($conn, $_POST['name']);
$id = mysqli_real_escape_string($conn, $_POST['id_last']);
$id2=+$id;
$sql="INSERT INTO file (name, unique_id )
VALUES ('$name','$name$id2')";
Try with this 试试这个
$id = "ABHI1";
$IncrementID = substr($id, -1) +1;
echo substr_replace($id,$IncrementID,-1);
Out put 放出
ABHI2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.