这是我在PHP中运行的第一个表查询PersonID是表employee的主键,它是经验的外键。
$query = mysqli_query($conn,"UPDATE employee SET Firstname = $fname, Lastname =$lname, email_id =$email, Mobile_no =$mobile, city=$city WHERE PersonID = $userid");
我的第二个表格查询
$query = mysqli_query($conn,"UPDATE experience SET Company_name = $com, Location =$local, Year_Of_Experience =$year, Description =$description WHERE id = $userid");
任何人都知道如何使用具有多列的公共ID更新两个表?
答案 0 :(得分:0)
为值添加引号。
$query = mysqli_query($conn,"UPDATE employee SET Firstname = '$fname', Lastname ='$lname', email_id ='$email', Mobile_no ='$mobile', city='$city' WHERE PersonID = '$userid'");
此方法容易出现安全漏洞。我建议使用预准备语句来提高安全性。你可以在这里学习如何做到这一点 http://php.net/manual/en/mysqli.prepare.php 和 https://www.w3schools.com/php/php_mysql_prepared_statements.asp