Home > Backend Development > PHP Tutorial > mql查询删除更新嵌入求指导php

mql查询删除更新嵌入求指导php

WBOY
Release: 2016-06-23 14:00:33
Original
1104 people have browsed it

譬如一个msq数据库里有apple,banna,lemon,orange四张表,其中apple表里有brand,color,name,comment四个字段,要求通过对name的查找来修改或删除comment的数据,用完整的sql语句怎么写?(确保成功运行的例子,特别注意标点的规范)
php写


回复讨论(解决方案)

用的什么数据库?

用的数据库是                  mysql

update apple set `comment`='xxx' where name='aa'

set 后面接双引号还是单引号啊?

(以下为完整代码,我不知道错在哪?好像是语法上的引号问题)



 
session_start();
if(isset($_SESSION['nowuser'])){
$username= $_SESSION['nowuser'];    
$reason=$_POST['reason'];

//检查表单
if(strlen($reason) >0){

 $sql = "select * from module1 where username='".$username."' "; 
update reason set `comment`='$reason' where name='$username';
$sql = "INSERT INTO module1(reason)VALUES('reason')";
if(mysql_query($sql,$conn))
    exit('提交成功!);
else
     echo"提交失败!";


}else{
exit('请填写完空白处再进行提交!返回');}

}else{
     exit('未登入!返回');
?>

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