1 Answers to this question

Ans: You can obtain the results in two different ways

Way -1:

$param = "%{$_POST['user']}%";

$stmt = $db->prepare("SELECT id,username FROM users WHERE username LIKE ?");

$stmt->bind_param("s", $param);

$stmt->execute();

$stmt->bind_result($id,$username);

while ($stmt->fetch()) {

  echo "Id: {$id}, Username: {$username}";

}

Way -2:

$param = "%{$_POST['user']}%";

$stmt = $db->prepare("SELECT id, username FROM users WHERE username LIKE ?");

$stmt->bind_param("s", $param);

$stmt->execute();

$result = $stmt->get_result();

while ($row = $result->fetch_assoc()) {

    echo "Id: {$row['id']}, Username: {$row['username']}";

}

If you want to unleash your potential in this competitive field, please visit the Web Development Training page for more information, where you can find the       and       as well.

For more updates on the latest courses stay tuned to HKR Trainings.

WhatsApp
To Top