0

Situation: first I will enter word in the search bar, and then how will the result be on the table? Please help me. I really need it for my thesis.

 require('connection.php');

     if (isset($_POST['submit']))
       {
        $param1=$_POST['search'];
        $checker = true;

        if(Empty($_POST['search']) || $_POST['search']==" ")
            {
                echo "Please Enter a Information";
                $checker = false;
            }
        if($checker == true)
            {       
                $result = mysql_query("SELECT * FROM user WHERE lastname LIKE %$param1% OR        
firstname LIKE %$param1% OR middlename LIKE %$param1% OR IDno LIKE %$param1% OR username LIKE 
%$param1% OR email LIKE %$param1% OR birthday LIKE %$param1% OR guardian LIKE %$param1% OR  
 gradelevel LIKE %$param1% OR section LIKE %$param1%;");
                while ($row = mysql_fetch_assoc($result)) 
                    {
                       ?????
                    }
            }
    }
?>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Unrelated, but protip: Stop using the mysql family of functions. Use mysqli instead. SEE: http://stackoverflow.com/questions/8891443/when-should-i-use-mysqli-instead-of-mysql – Patrick James McDougle Oct 09 '14 at 17:31
  • possible duplicate of [Displaying result for a particular record through PHP- MySQL Search](http://stackoverflow.com/questions/9193523/displaying-result-for-a-particular-record-through-php-mysql-search) – Sanoob Oct 09 '14 at 17:37

1 Answers1

1
<?php
    require('connection.php');

    if (isset($_POST['submit']))
    {
        $param1=$_POST['search'];
        $checker = true;

        if(Empty($_POST['search']) || $_POST['search']==" ")
        {
            echo "Please Enter a Information";
            $checker = false;
        }
        if($checker == true)
        {       
            $result = mysql_query
            ("
            SELECT * 
            FROM user 
            WHERE lastname 
            LIKE %$param1% 
            OR firstname 
            LIKE %$param1% 
            OR middlename 
            LIKE %$param1% 
            OR IDno 
            LIKE %$param1% 
            OR username 
            LIKE 
            %$param1% 
            OR email 
            LIKE %$param1% 
            OR birthday 
            LIKE %$param1% 
            OR guardian 
            LIKE %$param1% 
            OR gradelevel 
            LIKE %$param1% 
            OR section 
            LIKE %$param1%
            ");
            $fetch = array();
            while ($row = mysql_fetch_assoc($result)) 
            {
                $fetch[] = $row;
            }
        }
    }
?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
ehwas
  • 248
  • 1
  • 9