Hi Herman,

Try something like this...

$dbname = "my_db";
$tablename = "my_table";

$table_def = "item_id MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT,";
$table_def .= "item_name VARCHAR(50) BINARY NOT NULL,";
$table_def .= "lastaccessed TIMESTAMP(14),";
$table_def .= "PRIMARY KEY (item_id),";
$table_def .= "UNIQUE item_id (item_id)";

if(!mysql_select_db($dbname)) die;

if(!mysql_query("CREATE TABLE $tablename ($table_def)")) die;

It's not the prettiest code in the world, I am sure of that. But it should
give you a start.

I hope this helps!

-----Original Message-----
From: Herman Wapenaar [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 11:00 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Creating tables


Hi everyone

I am using a website based in the states to which is PHP enabled. I am using
MySQL.

Is there a way to create a table with PHP? I do not see any command for
that.

I have loaded MySQL for Windows but the server runs MySQL on Unix. I don't
know if the file structure is different. Maybe that is why I can not read
it?

Thanks
Herman Wapenaar



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to