RE: [PHP-DB] Creating tables

From: Date: Wed, 25 Apr 2001 06:05:58 +0000
Subject: RE: [PHP-DB] Creating tables
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8861@lists.php.net to get a copy of this message
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:hwapen@iafrica.com] Sent: Tuesday, April 24, 2001 11:00 PM To: php-db@lists.php.net 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: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#8861) next »