0

Making a php webpage which queries data based on variables in a form using a prepared statement and I want the prepared statement to include a wildcard to just dump all records if no input is given:

if (!($stmt = $conn->prepare("SELECT * FROM wan_equipment WHERE EQUIP_CND LIKE ?"))) {
    echo "Prepare failed: (" . $conn->errno . ") " . $conn->error;
}

So if the value '*' is bound, I want the SQL to select all records, but if I bind like so:

if(isset($_POST['tagfilter'])) {$tft = $_POST['tagfilter'];} else {$tft = '*' ;}
if (!$stmt->bind_param('s', $tft)) {
    echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
}

Then make a variable dump of the result, I get an empty array instead of a full dump.

What variable can I pass as $tft in order to make the SQL select all?

0 Answers0