Skip to content

Instantly share code, notes, and snippets.

@hhypnos
Last active March 7, 2018 08:29
Show Gist options
  • Save hhypnos/ba8bec65d6efd4f637e251e831d99cfb to your computer and use it in GitHub Desktop.
Save hhypnos/ba8bec65d6efd4f637e251e831d99cfb to your computer and use it in GitHub Desktop.
Search
<?php
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT lastname FROM TableName";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
if(substr_count($row["lastname"],"iii")){
echo $words[$i]. " ";
}
}
} else {
echo "0 results";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment