小编jay*_*urg的帖子

搜索具有一个或多个(多个)参数的表单

我已经掌握了基础知识,在那里我创建了两个文件,一个用户输入搜索参数的搜索表单,以及创建输入项目的结果文件.为简单起见,我们将搜索表单文件指定为search.php,将结果页面指定为results.php.

编辑:清理标签礼仪,使阅读更顺畅.

search.php中

<?php

    if(!empty($_POST['id']) && isset($_POST['id'])) {

    header("Location: ?m=search.results&id=".$_POST['id']."");

    } elseif(!empty($_POST['major']) && isset($_POST['major'])) {

    header("Location: ?m=search.results&major=".$_POST['major']."");

    } elseif(!empty($_POST['college']) && isset($_POST['major'])) {

    header("Location: ?m=search.results&college=".$_POST['college']."");

    } elseif (!empty($_POST['name']) && isset($_POST['name'])) {

    header("Location: ?m=search.results&name=".$_POST['name']."");


    } elseif (!empty($_POST['id']) && !empty($_POST['college']) && !empty($_POST['major']) 
                                  && isset($_POST['submit']) && !empty($_POST['name'])) {

        echo "<div class='alert alert-danger'>No students found. Please try different parameters.</div>";



    }

    ?>


    <h4>Search</h4>

    <form method="POST">
        <table width="100%">

    <tr><td>ID:</td><td> <input type="text" name="id" class="form-control"></textarea></td></tr>

     <tr><td>Name:</td><td> <input type="text" name="name" class="form-control"></textarea></td></tr>

     <tr><td>Major:</td><td><select name="major" class="form-control"><option></option><?php echo majorSelect(); ?></select></td></tr>

     <tr><td>College:</td><td><select name="college" class="form-control"><option></option><?php …
Run Code Online (Sandbox Code Playgroud)

php parameters search isset

2
推荐指数
1
解决办法
4653
查看次数

标签 统计

isset ×1

parameters ×1

php ×1

search ×1