MySQL Forums
Forum List  »  PHP

Re: How to use $POST variable in WHERE clause
Posted by: Peter Brawley
Date: February 18, 2021 10:32AM

Given connection $conn and existing $_POST['minuserid'] and $_POST['minuserid'] elements ...

$minuserid = $conn->real_escape_string( $_POST['minuserid'] );
$maxuserid = $conn->real_escape_string( $_POST['maxuserid'] );
$sql = "SELECT user_id, username, user_email FROM table_users WHERE user_idd>=$minuserid and user_id<=$maxuserid";

Notes:

1 double quotes support variable value replacement, single quotes do not.

2 MySQL has deprecated && as a symbol for AND.

Options: ReplyQuote


Subject
Written By
Posted
Re: How to use $POST variable in WHERE clause
February 18, 2021 10:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.