dp20011 2011-04-18 12:23
浏览 19
已采纳

php手动增加会员号码

i've got hundreds of people joining my website and create an membership id for them. i just created a new column in the database called user_no.

  • whats the mysql query for incrementing the membership no.
  • is it possible to start with AE then numbers ie: AE0001, AE0002, .... and it starts with 4 number not AE1, AE2..

mysql query:

UPDATE user SET user_no=..??

and on PHP side, how do i increment it? if there is a new member join in.

$db->query("INSERT INTO user (user_no) VALUES(AE'$user_no')");
  • 写回答

2条回答 默认 最新

  • douhao3562 2011-04-18 12:26
    关注

    Why not use an autoincrement field and append AE to it? Autoincrement will be carried out by MySQL so you don't have to worry about it in PHP : http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

    And to display your user key in the format of AE0001 you can do

    $id = 'AE' . str_pad($autoincrementid, 5, "0", STR_PAD_LEFT);
    

    http://php.net/manual/en/function.str-pad.php

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

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大