【发布时间】:2015-08-04 18:01:32
【问题描述】:
我正在尝试在名为“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>
【问题讨论】:
-
你的问题是什么?
-
一件事的回声会给你的一天带来阻碍。您也没有使用
$a循环任何内容。 -$a++到多少次和多少次迭代? -
php 不是递归可嵌入/可执行的...所以,不,您不能使用此代码。你不能编写自己的语法并期望它“正常工作”
-
可以让它进入一个while循环,比如while($a