duandiao3961 2014-01-13 02:15
浏览 106
已采纳

自动增加客户编号。

So, I'm trying to create a database where the user is making client pages. I figured out how to upload there first name,last name,telephone,fax,e-mail,client number to the database.My question is how do I automatically increase the client number, when ever the end-user is creating a new page.Ex first time PCO-14-1, next time without them typing in PCO-14-2 it should do it automattically. Any suggestion where do I start from.

By the way the languages i'm using are html,php,javascript and phpmyadmin.

  • 写回答

2条回答 默认 最新

  • duanleixun2439 2014-01-13 02:22
    关注

    First is that you need to have another column only for ID's(int) in order to get the max data or last ID inserted. You can do it by this way:

     // you connect in your database here
    
    $query = mysqli_query("SELECT MAX(ID) as id FROM tbl_newPage") or die(mysqli_error());
    $result = mysqli_fetch_assoc($query);
    $ID = $result['id'] + 1;
    
    $newID = "PCO-14-" .$ID; // the new id that is already incremented 
    

    Hopes this helps bro.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?