Home  >  Article  >  Backend Development  >  How to add fields in php mysql

How to add fields in php mysql

藏色散人
藏色散人Original
2020-08-07 10:45:553038browse

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.

How to add fields in php mysql

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=&#39;text/javascript&#39;>alert(&#39;增加成功!&#39;);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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn