03-Apr-2023
.
Admin
Hi Dev,
This tutorial is focused on how to use the like operator with the where clause in PHP MySQL. you'll learn how to use like operator with where clause in the PHP MySQL. We will use how to use a like operator with a where clause in PHP MySQL. if you have a question about how to use a like operator in a where clause in PHP MySQL then I will give a simple example with a solution.
Now, let's see the article on how to use the like operator with a where clause in the PHP MySQL. it's a simple example of how to use a like operator with a where clause in PHP MySQL. you can understand the concept of how to use a like operator with a where clause in PHP MySQL. if you have a question about how to use a like operator in a where clause in PHP MySQL then I will give a simple example with a solution.
Example:
index.php
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "myDB";
// Create a connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check the connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id, firstname, lastname FROM MyGuests WHERE firstname like 'J%'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "Name:" . $row["firstname"].;
}
}else{
echo "0 results";
}
mysqli_close($conn);
?>
Output:
Name: John
I hope it could help you...
#PHP