Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP的另一个页面中显示输出结果_Php_Mysql - Fatal编程技术网

在PHP的另一个页面中显示输出结果

在PHP的另一个页面中显示输出结果,php,mysql,Php,Mysql,我有一个旅游搜索应用程序,用户可以根据三个不同的参数(地区、国家和持续时间)搜索可用的旅游。目前,我使用的代码在同一页面中显示输出结果。我希望输出结果显示在不同的页面中 下面是我的PHP代码: <?php mysql_connect("localhost", "root", ""); mysql_select_db("byp"); if(isset($_POST['submit'])){ $region=$_POST['region'];

我有一个旅游搜索应用程序,用户可以根据三个不同的参数(地区、国家和持续时间)搜索可用的旅游。目前,我使用的代码在同一页面中显示输出结果。我希望输出结果显示在不同的页面中

下面是我的PHP代码:

<?php
      mysql_connect("localhost", "root", "");
    mysql_select_db("byp");

    if(isset($_POST['submit'])){
        $region=$_POST['region'];
        $country=$_POST['country'];
        $duration=$_POST['duration'];

        //define the index for the All option
        $optionAllValue = 0; //add here the option index value used for the 'All' option
        //define the where clause for the query
        //in order to avoid many conditions verifications, we start it as 1=1
        $whereClause = "1=1";

        //now we check if the option selected for each field is not the value defined for the option 'All'
        //this is just an example, and the best would be to create a function to avoid the replication of code 
        if($region != $optionAllValue)
        {
            $whereClause = $whereClause." and region='$region'";
        }
        if($country != $optionAllValue)
        {
            $whereClause = $whereClause." and country='$country'";
        }
        if($duration != $optionAllValue)
        {
            $whereClause = $whereClause." and duration='$duration'";
        }

        $query = "select * from byp_tour where ".$whereClause;

        //original query select * from byp_tour where region='$region' and country='$country' and duration='$duration'"
        $tour = mysql_query($query);
        $tourNum = mysql_num_rows($tour);

        if($tourNum >0){

            while($result=mysql_fetch_array($tour)){

                $tour_name = $result['tour_name'];
                $tour_detail = $result['tour_detail'];

                echo "Tour Name: $tour_name";  // HERE IS THE OUTPUT RESULT
                echo "<br />";
                echo "Tour Detail: $tour_detail";
                echo "<br />";
                echo "<br />";
                echo "<br />";
            }
        }
        else{
            echo "No Tour Found";
            echo "<br />";
            echo "<br />";
        }
    }
?>
<!DOCTYPE html>
<html>
    <head>
        <title>BYP Test</title>
    </head>
    <body>
        <form action="searchtest.php" method="post">
            <div>
                <label>Region</label>
                <select id="region" name="region">
                    <option value="0">All</option>
                    <option value="1">South East Asia</option>
                    <option value="2">Africa</option>
                    <option value="3">Europe</option>
                    <option value="4">America</option>
                    <option value="5">Australia</option>                               
                </select>
            </div>
            <div>
                <label>Country</label>
                <select id="country" name="country">
                <option value="0">All</option>
                <option value="1">Cambodia</option>
                <option value="2">Thailand</option>
                <option value="3">Vietnam</option>
                <option value="4">Myanmar</option>
                <option value="5">Laos</option>
                <option value="6">Ethiopia</option>
                <option value="7">France</option>
                <option value="8">New York City</option>
                <option value="9">Melbourne</option>
            </select>
        </div>
        <div>
            <label>Duration</label>
            <select id="duration" name="duration">
                <option value="0">All</option>
                <option value="1">5 Days</option>
                <option value="2">10 Days</option>
            </select>
        </div>
        <input type="submit" name="submit" value="submit" />
        </form>
    </body>
</html>
您需要将target=“\u blank”添加到



您希望我们…?Image:404找不到…注意:您正在使用的
mysql.*
函数正在被弃用,并将从未来的PHP版本中删除。您不应该使用它们编写新代码,请改用
mysqli\u*
或PDO。我想获得有关确切代码的帮助,以便在另一页中回显结果。谢谢,我找到了解决方案。我已将PHP代码放在另一个文件show_result.PHP中。我修改了这一行
<form action="searchtest.php" method="post" target="_blank">