我有一个jQuery跟踪onChage .change()事件的形式,因此当发生更改时,它会运行ajax请求,并在列,id和url中传递值.
在这里,我有应该更新数据的PHP代码.
我的问题是现在如何动态构建MysqL字符串.
以及如何回显刚刚在数据库上更改的更改/更新.
@H_502_12@<?PHP require_once('Connections/connect.PHP'); ?> <?PHP $id = $_GET['id']; $collumn = $_GET['collumn']; $val = $_GET['val']; ?> <?PHP MysqL_select_db($myDB,$connection); // here i try to build the query string and pass in the passed in values $sqlUpdate = 'UPDATE `plProducts`.`allPens` SET `$collumn` = '$val' WHERE `allPens`.`prodId` = '$id' LIMIT 1;'; // here i want to echo back the updated row (or the updated data) $seeResults = MysqL_query($sqlUpdate,$connection); echo $seeResults ?>
这个例子好吗?
@H_502_12@$sqlUpdate = 'UPDATE `plProducts`.`allPens` SET "{$collumn}" = "{$val}" WHERE `allPens`.`prodId` = "{$id}"LIMIT 1;';
最佳答案