MYSQL主键自增用法
<?php
header('content-type:text/html;charset=utf-8');
$mysqli=new mysqli('localhost','root','root','stu');
$i=1;
// while ($i <= 100) {
// $sql="insert into user(uname,uage) values ('hdw{$i}',$i)";
// $mysqli->query($sql);
// $i++;
// }
$sql='select * from user';
$result=$mysqli->query($sql);
while ($row=$result->fetch_assoc()) {
echo "学员名:".$row['uname']."\t年龄:".$row['uage']."<br/>";
}
?>
create table user(
id integer primary key,
firstname varchar(200) not null,
lastname varchar(200) not null,
age integer
);
alter table user modify id integer auto_increment ;
alter table user modify id integer default '1';
alter table user add createtime timestamp default current_timestamp;
create table dd(
id int primary key not null auto_increment,
name varchar(20),
time timestamp default current_timestamp
);