php Mysql method to add fields: first create a PHP sample file; then add fields through the statement "alter table diy_form add name_1 varchar(50) not null"; finally determine whether the fields are added successfully.
Recommendation: "PHP Video Tutorial"
PHP adds MYSQL field
Specific question:
How to write code to add MYSQL fields in PHP? For example, is the table diy_form? How to add a field named name_1 to the table using PHP?
Implementation method:
//增加字段 sql 语句, <?php $sql="alter table diy_form add name_1 varchar(50) not null"; //php执行语句 $result=mysql_query($sql); //判断是否成功 if($result){ echo (" <script type='text/javascript'>alert('增加成功!');history.back();;</script>" ); exit; } ?>
When testing, please remove the comments.
The above is the detailed content of How to add fields in php mysql. For more information, please follow other related articles on the PHP Chinese website!