I am trying to make some prepared statements using the LIKE keyword in sql but it's giving me:
Warning : mysqli_num_rows() expects parameter 1 to be mysqli_result, object given
PHP code:
if(isset($_POST['search_acc'])){
$p = $_POST['search_text'];
$search_text = "%p%";
$stmt = $conn->prepare("SELECT * FROM accountants WHERE name LIKE ? ");
$stmt->bind_param("s",$search_text);
$stmt->execute();
}
if (mysqli_num_rows($stmt) > 0) {
while ($RowaccountantsList = mysqli_fetch_assoc($stmt)) {
$accountantFullName = mysqli_real_escape_string($conn, $RowaccountantsList['name']);
$accountantId = mysqli_real_escape_string($conn, $RowaccountantsList['ts_number']);
$accountantCityTown = mysqli_real_escape_string($conn, $RowaccountantsList['city_town']);
$DB_id = mysqli_real_escape_string($conn, $RowaccountantsList['id']);
$nrc = mysqli_real_escape_string($conn, $RowaccountantsList['nrc']);
$profile_pic = mysqli_real_escape_string($conn, $RowaccountantsList['profile_pic']);
$RegisteredDate = mysqli_real_escape_string($conn, $RowaccountantsList['registered_date']);
}
html search form:
<form method="post" action="">
<div id="custom-search-input">
<div class="input-group col-md-12 align-center">
<input name="search_text" type="text" class="form-control input-lg" placeholder="Enter email, phone or username" />
<span class="input-group-btn">
<button name="search_acc" class="btn btn-info btn-lg" type="submit">
<i class="fa fa-search" aria-hidden="true"></i>
</button>
</span>
</div>
</div>
</div>
</form>