简体   繁体   English

如何借助 php 中的选择选项将值从一个页面传递到另一个页面?

[英]How i can pass values from one page to another with the help of select option in php?

I have a simple code where i query my database, and set the values in a option list, as shown in the code below :我有一个简单的代码,用于查询我的数据库,并在选项列表中设置值,如下面的代码所示:

    <?php
        $postQuery="SELECT DISTINCT labelName FROM posts";
        $postResult=mysqli_query($conn,$postQuery);
     ?>


    <form action="inc/set.php" method="post" enctype="multiform/partdata">
        <input type="text" name="title" value="Add Title"><br>
        <select name="lable" >

            <option value="empty">Empty</option>

            <?php foreach ($postResult as $post) {;?>

                <option value="<?php echo $post['labelname'];?>"><?php echo $post['labelName'];?> 
                </option>

            <?php } ;?>

        </select>

How can i pass the values from the option list that are in php code in the another page as shown in the form inc/set.php .我如何从选项列表中传递另一个页面中 php 代码中的值,如表单 inc/set.php 所示。 And what would be the standart and best way to do that.什么是标准和最好的方法来做到这一点。 Thank you for yo help folks.谢谢你帮助人们。

Use a session variable!使用会话变量! See: "PHP Sessions" at W3Schools .请参阅: W3Schools 上的“PHP 会话”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM