alter table using php and sql

by Mohan 2014-03-19 13:17:06


alter table using php and sql



Here is a sample code to add a column to a database table using php and mysql.




$username = "root";
$password = "";
$hostname = "localhost";
$dbname = "test";
$link = mysql_connect($hostname,$username,$password) or die('Cant connect to database');
$lnk=mysql_select_db($dbname,$link) or die('Cant select the database');
$query = "ALTER TABLE `sample` ADD COLUMN `status` INT(1) NOT NULL AFTER `title`";
$res=mysql_query($query);


On executing the code ,new column with name status will be added after title column on table sample.

Tagged in:

600
like
0
dislike
0
mail
flag

You must LOGIN to add comments