mysql怎么 写我每添加一条数据 ID+1   
比方说我有2个字段  一个是ID  一个是内容   如果我添加一条内容  自动会生成 ID  内容
1   fwefawf会自动生成ID 1 如果再添加一条内容 就会自动生成ID2 以此类推ID  内容1   fwefawf
2   fwafawddd

解决方案 »

  1.   

    ID 字段改成自动递增id int AUTO_INCREMENT
      

  2.   


    这些内容要插入mysql中 在mysql里设置id为自动增长的 id int AUTO_INCREMENT 
    然后 在php代码中活得内容后 再插入数据库时 并不需要设置id的值  mysql会自动插入增长的id
    比如 $sql="insert into post set content='123'"; $db->query($sql); 
      

  3.   

    在mysql中创建表时设置id为自动增长,php使用insert语句往表里插数据时,id便会自动+1以下是创建mysql表的示例:create table `Table1`
    (
      ` id` int(11) not null auto_increment,
      `content` varchar(255) not null default ''
    );
      

  4.   

    我在phpadmin找不到 让我ID改为AUTO_INCREMENT   在哪里 
      

  5.   

    alter table pic_1 add id int default 0 not null   auto_increment ,add primary key (id);  
    我运行了这个SQL语句 没有效果啊  还是不会增加字段  我要在pic_1表添加id自增字段
      

  6.   

    运行这句,把刚id字段删了,再试下
    alter table pic_1 add id int(9) primary key auto_increment