Skip to content

Instantly share code, notes, and snippets.

@ityulkanov
Created February 10, 2017 20:14
Show Gist options
  • Save ityulkanov/526a4e192e897c178f73594e3401a962 to your computer and use it in GitHub Desktop.
Save ityulkanov/526a4e192e897c178f73594e3401a962 to your computer and use it in GitHub Desktop.
<?php include ("db.php"); ?>
<?php
mysqli_set_charset($connection, "utf8");
$search = $_POST['search'];
if (!empty($search)) {
$query = "SELECT * FROM records WHERE phone LIKE '$search%' ";
$search_query = mysqli_query($connection, $query);
$num_rows = mysqli_num_rows($search_query);
?><p><?php echo "<span id='results'>Результатов: {$num_rows}"; ?> </p>
<?php
if (!$search_query) {
die('QUERY FAILED' . mysqli_error($connection));
# code...
}
while($row = mysqli_fetch_array($search_query)) {
// get data from each row to display it in the results
$phone = $row['phone'];
$description = $row['description'];
$date_added = $row['date_added'];
$id = $row['id'];
?>
<?php
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment