我的编码有什么问题,因为它不起作用?
$empsql("SELECT * FROM employees WHERE e_id ='$ed_id' ");
if($rows > 0) {
$empsql('UPDATE employees SET name = "'.$name.'" , description = "'.$description.'" , telephone = "'.$telephone.'" , email = "'.$email.'" WHERE e_id = "'.$ed_id.'" ');
}
else
{
$empsql("INSERT INTO employees (name,description,telephone,email) VALUES ('$name','$description','$telephone','$email') ");
}
答案 0 :(得分:0)
你应该坚持基础,因为你的语法没有意义。这段代码更有意义。
$empsql = "SELECT * FROM employees WHERE e_id ='$ed_id'";
$rows = mysql_fetch_array(mysql_query($empsql));
if(!empty($rows)) {
mysql_query('UPDATE employees SET name = "'.$name.'" , description = "'.$description.'" , telephone = "'.$telephone.'" , email = "'.$email.'" WHERE e_id = "'.$ed_id.'" ');
}
else
{
mysql_query("REPLACE INTO employees (name,description,telephone,email) VALUES ('$name','$description','$telephone','$email') ");
}