如何使用以下代码创建表 [英] How to create table using this below code
问题描述
先生,
请告诉我们如何使用以下代码创建表格
我尝试了什么:
$ table_name =test;
$ a =r1,r2,r3,r4;
$ abc =(explode(,,$ a));
foreach($ abc as $ x)
{
echo $ x;
$ query =CREATE TABLE $ table_name。
'(id INT(6)UNSIGNED AUTO_INCREMENT PRIMARY KEY,
'。$ x。'varchar(30))'
if($ con> exec($ query))
{
echo表MyGuests创建成功;
}
else
{
echo再试一次;
}
}
之后这个表应该在数据库中创建,但事实并非如此。为什么我得到解决方案。请指导我
table_name =测试;
a =r1,r2,r3,r4;
abc =(explode(,,
Sir,
please tell how to create table using below code
What I have tried:
$table_name = "test";
$a ="r1,r2,r3,r4";
$abc = (explode(",",$a));
foreach($abc as $x)
{
echo $x;
$query = "CREATE TABLE $table_name".
'(id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
'.$x.' varchar(30))'
if($con->exec($query))
{
echo "Table MyGuests created successfully";
}
else
{
echo "try again";
}
}
after this the table should created in database but it is not.Why I am getting the solution.Please guide me
table_name = "test";
a ="r1,r2,r3,r4";
abc = (explode(",",
这篇关于如何使用以下代码创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!