RE: Create table example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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/



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux