How to add/create a table in mysql using PHP?

To make a table in mysql using PHP use the following code:

$query = mysql_query("CREATE TABLE new_table (column_1 INT(12) NOT NULL AUTO_INCREMENT PRIMARY KEY,column_2 TEXT NOT NULL, column_3 TEXT, column_4 VARCHAR(15) NOT NULL, column_5 INT(12))");

The above code will make 5 columns, the first column is the index column with auto increment, the second and third column is TEXT type. Fourth column is VARCHAR type and fifth column is integer type.

Show Form
No comments yet. Be the first to add a comment!