我的PHP文件在搜索之前显示数据库中的数据

时间:2016-08-01 07:15:41

标签: php

<?php 
    require_once( "member.php"); 
    $query="" ; 
    if(!empty($_GET[ "query"])) {
      $query=$ _GET[ "query"]; 
    }
?>

<!DOCTYPE html>
<html>

<head>
    <title>Search Area</title>
</head>

<body>

    <h1 align="center">Members</h1>

    <form class="modal-content" method="get" action="indexx.php">
        <div class="container" style="background-color:#f1f1f1">
            <div class="imgcontainer">
                <img src="images/logo.png" alt="Avatar" class="avatar">
            </div>
            <input type="text" id="query" value="<?php echo $query; ?>" placeholder="Enter Imei No./Job No." name="query">
            <button type="submit" value="Search">Check</button>
      </div>
    </form>

    <p>
        <div>
            <table>
                <tr>
                    <th>First Name</th>
                    <th>Last Name</th>
                    <th>Gender</th>
                    <th>Birth Date</th>
                    <th>Address</th>
                </tr>


    <?php //paging $page=1 ; if(!empty($_GET[ "page"])){ $page=$ _GET[ "page"]; } if($page==0 ){ $page=1 ; } $limit=1 0; $offset=( $page-1)*$limit; $data=g etMembers($query, $limit, $offset); $totalData=c ount($data); foreach( $data as $value){ ?>
    <tr>
        <td>
            <?php echo $value[ "firstname"]; ?>
        </td>
        <td>
            <?php echo $value[ "lastname"]; ?>
        </td>
        <td>
            <?php echo $value[ "gender"]; ?>
        </td>
        <td>
            <?php echo $value[ "birthdate"]; ?>
        </td>
        <td>
            <?php echo $value[ "address"]; ?>
        </td>
    </tr>
    <?php } //Total All Rows $totalRows=g etMemberTotalRows($query); ?>

    </table>

    </div>
</body>

</html>

我想为我的会员创建搜索网络..一切都还可以,但是 我的搜索php网站在我搜索之前显示来自数据库的数据..请帮助我..我是新的PHP .. 如何在点击检查按钮之前隐藏数据? 我的英语不好......

1 个答案:

答案 0 :(得分:0)

$data = getMembers($query, $limit, $offset);

仅在设置了搜索值$_GET["data"]时调用

if(isset($_GET["query"]))
    $data = getMembers($query, $limit, $offset);
else
    die("Nothing to search for");   // Or anything else for that matter
相关问题