Jump to content

Create table


Afzaal.Ahmad.Zeeshan

Recommended Posts

i need to ask where to put this code ?? so that it could run.. CREATE TABLE Profiles( UniqueID AutoIncrement NOT NULL PRIMARY KEY, Username Text (255) NOT NULL, ApplicationName Text (255) NOT NULL, IsAnonymous YesNo, LastActivityDate DateTime, LastUpdatedDate DateTime, CONSTRAINT PKProfiles UNIQUE (Username, ApplicationName))

Link to comment
Share on other sites

Put it in a mysql_query(). Here's a n example:

<?php// connect to your MySQL database hererequire_once "connect_to_mysql.php";// Create an sql command structure for creating a table$tableCreate = "CREATE TABLE members (			    id int(11) NOT NULL auto_increment,			    username varchar(255) NOT NULL,			    email varchar(255) NOT NULL,			    password varchar(255) NOT NULL,			    website varchar(255) NULL,			    account_type enum('a','b','c') NOT NULL default 'a',			    PRIMARY KEY (id),			    UNIQUE KEY email (email)			    )";// This line uses the mysql_query() function to create the table now$queryResult = mysql_query($tableCreate);// Create a conditional to see if the query executed successfully or notif ($queryResult === TRUE) {	    print "<br /><br />Success in TABLE creation! Happy Coding!";} else {	    print "<br /><br />No TABLE created. Check";}// close mysql connectionmysql_close();?>

Link to comment
Share on other sites

you can also do that in mysql console or use friednly convenient application like phpmyadmin. creating tables and databases usually done outside php script.

  • Like 1
Link to comment
Share on other sites

Great point birbal. Frankly, that's the way I do it now, but in the beginning I used php.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...