phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP MySQL: Adding Field Table

Tag: mysql, database, table, field, add   Category: PHP Database
post: 03 Mar 2008 read: 1,644


php mysql basic step by step tutorial - part 15: You can add field table use the syntax as follow:

ALTER TABLE table_name ADD field_name field_type field_attribute

For example, we will add field "position" with the type of "varchar" and field length of 50 character into data_employees table.


<?
//the example of adding MySQL database field table
//add_field.php

//database connection
mysql_connect("localhost","root","admin");
mysql_select_db("employees");

$order1 = "ALTER TABLE data_employees 
           ADD position varchar(255)";
$add_field = mysql_db_query("employees",$order1);

if ($add_field){
	echo ("<br><br>Field position succeeds in adding");
}else{
	echo ("<br><br>Field position fails in adding");
}
?>


Series this article:
PHP MySQL: Connecting to Database Use mysql_connect()
PHP MySQL: Making Database Use mysql_create_db()
PHP MySQL: Making Table
PHP MySQL: The Data Type of Field
PHP MySQL: Char and Varchar Data Type
PHP MySQL: Data Type of Date
PHP MySQL: MySQL Syntax Orders
PHP MySQL: Inserting Data
PHP MySQL: Creating Form Insert Data
PHP MySQL: Display Data
PHP MySQL: mysql_fetch_row() Function
PHP MySQL: mysql_fetch_array() Function
PHP MySQL: Editing data
PHP MySQL: Deleting data
PHP MySQL: Adding Field Table
PHP MySQL: Editing Field Table
PHP MySQL: Deleting Field Table

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting