Search Filtering with PHP/MySQL

后端 未结 7 1908
执念已碎
执念已碎 2021-01-30 12:08

I\'m trying to create a search/filtering option in my blood donor application. Where donor can be searched by sex, name, blood group or by selecting all three. Here is my code

7条回答
  •  隐瞒了意图╮
    2021-01-30 12:42

    In this where you don't use validation, it is recomended not to use whether Field is EMPTY or NOT. Try below code, Hope it will work

    function search_donar($_POST) {
    
        $by_name = $_POST['by_name'];
        $by_sex = $_POST['by_sex'];
        $by_group = $_POST['by_group'];
        $by_level = $_POST['by_level'];
    
        $search_query = "SELECT * FROM donar WHERE name LIKE '%$by_name%' AND sex LIKE '%$by_sex%' AND blood_group LIKE '%$by_group%' AND  e_level LIKE '%$by_level%' ";
    
        $result = mysql_query($search_query);
    
        return $result;
    }
    

提交回复
热议问题