如何使用php在同一个数据库中创建多个表?

时间:2015-08-04 18:01:33

标签: php html mysql mysqli

我试图在同一个名为" new"的数据库中创建多个表,我想我们可以在查询代码中使用php来提供多个表名吗? 提前谢谢......

<?php
$a=0;
$con=new mysqli("localhost","root","","new") or die("Can not connect to database");
$sql=("create table table.'echo $a++;' ( num int, name varchar(50))");
$con->query($sql);
$con->close();
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

试试这个:

and

无论如何你必须执行多个create table SQL语句,我把它放在while循环中。