if(isset($_POST["trimite"]))
{
$nume=$_POST["nume"] ;
$prenume=$_POST["prenume"] ;
$bust=$_POST["bust"] ;
$talie=$_POST["talie"] ;
$sold=$_POST["sold"] ;
$par=$_POST["par"] ;
$img1=$_POST["imagine1"] ;
$img2=$_POST["imagine2"] ;
$img3=$_POST["imagine3"] ;
$idsal=$_POST["id_salariu"];
$id=$_GET["id"];
$update_query="UPDATE `model`
SET `nume` = '".$nume."'
AND `prenume` = '$prenume'
AND `bust` = $bust
AND `talie` = $talie
AND `sold` = $sold
AND `culoare_par` = '$par'
WHERE
`id_model`=$id";
$update_query1="UPDATE `poze`
SET `cale_poza` = '$img1'
AND `cale_poza1` = '$img2'
AND `cale_poza2` = '$img3'
WHERE
`id_model`=$id";
$update_query2="UPDATE `salariu`
SET `id_salariu` =$idsal
WHERE
`id_model`=$id";
echo 'MySQL server version: %s\n'. mysqli_get_server_info($connection);
$update=mysqli_query($connection, $update_query);
$update1=mysqli_query($connection, $update_query1);
$update2=mysqli_query($connection, $update_query2);
if ($update) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($connection);
}}
您好!
我在phpMyAdmin数据库中有这些列:nume(varchar), prenume(varchar), bust(int), talie(int),sold(int),par(varchar),cale_poza(varchar),cale_poza1(varchar),cale_poza2(varchar),id_salariu(int).
当我想在phpMyAdmin上运行这些查询时,它们可以工作,但是当我在php中运行它们时它们不起作用。例如,当我想将“nume”字段从“Prey”更新为“Prey1”时,“nume”字段将重新显示0.当我尝试更新时,所有字段都会收到相同的值。 提前谢谢!
答案 0 :(得分:0)
更改您的SQL查询并尝试
$update_query="UPDATE `model`
SET `nume` = '".$nume."'
,`prenume` = '$prenume'
,`bust` = $bust
,`talie` = $talie
,`sold` = $sold
,`culoare_par` = '$par'
WHERE
`id_model`=$id";
$update_query1="UPDATE `poze`
SET `cale_poza` = '$img1'
,`cale_poza1` = '$img2'
,`cale_poza2` = '$img3'
WHERE
`id_model`=$id";