我想在網站上製作一個表單,您可以在其中寫入要更新的產品的名稱,價格或圖像,並在每個字段旁邊的文本框中編寫您想要的新值IDK的爲什麼每次我寫的東西更新的唯一場的名稱和變化,而不是爲新的名稱前將其更改爲0,我使用的PHP代碼是這樣的:此更新查詢有什麼問題?
<?php
mysql_connect("localhost","paradise_root","gantzminus1");
mysql_select_db("paradise_dbsalon");
$nombre = $_POST['txtnombre'];
$precio = $_POST['txtprecio'];
$imagen = $_POST['txtimagen'];
$nombre2 = $_POST['txtnombre2'];
$precio2 = $_POST['txtprecio2'];
$imagen2 = $_POST['txtimagen2'];
$_GUARDAR_SQL = "update productosyservicios set nombre = ('".$nombre2."') or precio = ('".$precio2."') or imagen = ('".$imagen2."') where nombre = ('".$nombre."') or precio= ('".$precio."') or imagen = ('".$imagen."') ";
$rst = mysql_query($_GUARDAR_SQL) or die("error".$_GUARDAR_SQL);
if($rst==true){
$rest=false;
}
?>
不知道什麼ü要實現的目標,但可以肯定的查詢是不正確的。你能解釋一下你想做什麼嗎? –
您不能使用或語句設置值,'set nombre =('「。$ nombre2。」')或precio =('「。$ precio2。」')或imagen =('「。$ imagen2。」 ')'有缺陷,你可能意指'set nombre =('「。$ nombre2。」'),precio =('「。'precio2。」'),imagen =('「。$ imagen2。」')'但我不知道給定我不知道是否要更新所有3如果任何值是真實的。 – xQbert
好吧想象一下,你有一個名稱,價格和圖像字段的表,然後你想從你的網站更新一行我試圖做,當你寫在例如一個文本框中的奶酪,並在下一個我寫香蕉的在那一行中的名稱從奶酪變成香蕉 – user36379