How to add fields in php mysql

藏色散人
Release: 2023-03-04 06:10:02
Original
3050 people have browsed it

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;
}
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template