Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "dbcon.php";
- class DataOperation extends database {
- public function search($table,$search_name) {
- $sql = "SELECT * FROM ".$table ." WHERE title LIKE '%$search_name%'";
- $query = mysqli_query($this->con,$sql);
- $count = mysqli_num_rows($query);
- if ($count == 0) {
- return false;
- }
- WHILE ($row = mysqli_fetch_assoc($query)){
- $array[]=$row;
- }
- return $array;
- }
- ?>
- // search.php
- <?php
- $obj = new DataOperation;
- if (strlen($search_name) > 2 ){
- $row = $obj->search('classified',$search_name);
- foreach ($row as $data) {
- echo '<h4>'.$data['title'].'</h4>';
- echo '<h4>'.$data['description'].'</h4>';
- echo '<h4>'.$data['id'].'</h4>';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement