如何将搜索栏的结果发布到表格中? PHP代码

时间:2014-10-09 17:28:39

标签: php mysql

情况:首先我会在搜索栏中输入单词,然后结果如何在桌面上? 请帮我。我的论文真的需要它。

 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)) 
                    {
                       ?????
                    }
            }
    }
?>

1 个答案:

答案 0 :(得分: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;
            }
        }
    }
?>