如何使用php mysql删除数据库中的特定列数据

时间:2016-02-09 18:09:07

标签: php mysql

嗨,我试图从数据库中删除某些列数据。这是我的删除查询代码。

var val="foo.bar";
var safevalue=encodeURIComponent(val).replace(/\./g, '%2E');

首先我将house_details数据插入数据库,但我只需删除该列中的特定数据

1 个答案:

答案 0 :(得分:2)

你想要的是function get_mime_type($filename) { $idx = explode( '.', $filename ); $count_explode = count($idx); $idx = strtolower($idx[$count_explode-1]); $mimet = array( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', // audio/video 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'docx' => 'application/msword', 'xlsx' => 'application/vnd.ms-excel', 'pptx' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', ); if (isset( $mimet[$idx] )) { return $mimet[$idx]; } else { return 'application/octet-stream'; } } ,而不是UPDATE,因为你想保留行,但只是清除/空白/取消设置行中的某些列。

DELETE

请注意,在查询中使用$res = "UPDATE house_details SET rental_annual_rent = NULL, rental_block = NULL, rental_street = NULL, rental_area = NULL, rental_town = NULL, rental_state = NULL, rental_pincode = NULL WHERE house_details_id='$id'"; 输入之前,您应该真正清理它,您应该对其进行参数化,还应该从id库迁移到mysqli或{ {3}}