Jump to content
Sign in to follow this  
Afzaal.Ahmad.Zeeshan

Create table

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

Share this post


Link to post
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();?>

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...