用变量名php mysql创建表 [英] Creating table with variable name php mysql
本文介绍了用变量名php mysql创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过表单创建带有变量名和列的表,这是我的查询
I'am trying to create table with variable name and columns via forms here's my query
$execute = mysql_query('CREATE TABLE '.$tName.'(
'.$cName.' '.$cType.' )');
它正在使用变量 $ tName $ c $创建表c>但它不会创建列。
And it's creating table with name from variable $tName
but it doesnt create the columns.
推荐答案
好的,尝试一下,我认为它给出了总体思路
OK try this, I think it gives the general idea
<?php
include 'connect-db.php';
$tbl_name='kerry';
$field1='name';
$field2='value';
$field3='date';
mysql_query("CREATE TABLE `{$tbl_name}`
(
$field1 varchar(15),
$field2 int,
$field3 date
)");
?>
这篇关于用变量名php mysql创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文