在MySQL PHP中添加额外的where子句

I have the following clause

$curSong = $wpdb->query("DELETE FROM ".$wpdb->prefix . "current_requests WHERE id='".$_POST['remove']."'");

and id like to add where page_id = $postid to the WHERE clause

simple I know but its just the syntax I am a little unsure of

Thanks

Henry

You mean this?

$query = sprintf("DELETE FROM %scurrent_requests WHERE id='%s' AND page_id='%s'", $wpdb->prefix, $_POST['remove'], $postid);
$curSong = $wpdb->query($query);

You can add more conditions to the where clause using "AND" operator.

$curSong = $wpdb->query("DELETE FROM ".$wpdb->prefix . "current_requests WHERE id='".$_POST['remove']."' AND page_id='$postid'");
you can write sql command like
Delete FROM Table where id=123 AND page_id=789 AND route_id=567

as much as you want, you can add more conditions using 'AND' logical       
operator.

if it helps you mark it as answered.

Modify your code...

Validate the user value to prevent SQL injection

Use htmlspecialchars() or htmlentities() by

$remove= htmlspecialchars($_POST['remove']);
$curSong = $wpdb->query("DELETE FROM ".$wpdb->prefix . "`current_requests` WHERE `id`='$remove' and `page_id` = '$postid'");

Note: You can add many condition by using and or Operator...