Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $connection = mysqli_connect('localhost', "my_user", "my_password", "my_db");
- $output = '';
- if(isset($_POST['search'])) {
- $searchkey = $_POST['search'];
- $searchkey = preg_replace("/[^0-9a-z]/i", "", $searchkey);
- //echo $searchkey;
- $query = mysqli_query($connection,"SELECT * FROM building_tc WHERE profile LIKE '%$searchkey%' OR server LIKE '%$searchkey%'") or die("Не удалось найти!");
- $count = mysqli_num_rows($query);
- //echo $count;
- if($count == 0) {
- $output = "Нет результатов поиска!";
- }
- else {
- while($row=mysqli_fetch_array($query)) {
- $profile = $row['profile'];
- $server = $row['server'];
- $output .= '<div>'.$profile.''.$server.'</div>';
- }
- }
- echo "$output";
- }
- ?>
- <form action="" method="post"> <input type="text" name="search" placeholder="Search"> <input type="submit" value="Поиск" /></form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement