RE: [PHP-DB] Create table example

From: Date: Sun, 30 Mar 2003 19:20:26 +0000
Subject: RE: [PHP-DB] Create table example
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26728@lists.php.net to get a copy of this message
> I have several (50+) tables I have to create in MySql. Is there a good PHP > example on creating a table via PHP?? I will probably do all of the > initial INSERTS that way, too. You don't create a table "via PHP", you simply pass a query through the mysql_query() function. If that query is a CREATE TABLE, then a table will be created. It can also be a INSERT, SELECT, SHOW, UPDATE, etc... All you're doing is passing a string through mysql_query() that MySQL is going to attempt to run as a query. So, for you, you'd need to use: Mysql_query("CREATE TABLE ... "); Mysql_query("INSERT INTO ... VALUES ... "); Fill in the blanks... Now, if you have all of these queries in a file, there may be an easier way to automate all of this, but you'll be doing the same thing, essentially. You can only pass one query at a time with mysql_query(). ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.db (#26728) next »