User selects operator from drop-down menu and use it in PHP function

SuzanneSigmundz

New Member
What I would like to achieve here is a user selects an operator, e.g. +, >, <, >= etc. and uses this in a Select statement in PHP. MY HTML code:\[code\] <label for="grade">Grade: </label> <select name="operator" id="operator"> <option value="">Select one</option> <option value="http://stackoverflow.com/questions/3572940/<">Less than</option> <option value="http://stackoverflow.com/questions/3572940/>">More than</option> <option valuehttp://stackoverflow.com/questions/3572940/="=">Equals to</option> </select> <input type="text" name="grade" id="grade" size="2" maxlength="2"> </input>\[/code\]My PHP code:\[code\] $operator = mysqli_real_escape_string($link, $_GET['operator']);$grade = mysqli_real_escape_string($link, $_GET['grade']);if ($grade != '') { $where .= " AND grade . '$operator' . '$grade'";}\[/code\]What I would like to achieve is 'AND grade > 3'. '3' could be another number. How could I change my codes to make PHP accepts it as a proper statement. Pardon my bad explanation here.
 
Back
Top