如何从另一个PHP文件中获取选择值?

How to get <select> value from another php file. Example :

index.php

$text = $_POST['text']
<select id="text">
    <option> text 1</option>
    <option> text 2</option>
    <option> text 3</option>
</select>

data.php

$sql= "SELECT column FROM table where $text='text 1'"

as you can read above, how to get value from $text in index.php and use it in data.php

I think you only forgot to add value for options itself

<form method="post" action="data.php">    
    <select name="text" id="text">
        <option value="text 1"> text 1</option>
        <option value="text 1"> text 2</option>
        <option value="text 1"> text 3</option>
    </select>
<input type="submit" value="Submit the form"/>
</form>

then add $_GET on your data.php

$text = $_GET['text']
$sql= "SELECT column FROM table where $text='ABCDE'"

hi you can passe this value with post method in index.php

 <form action="url_to_data.php" method="post">
        <select name="text">
           <option> text 1</option>
           <option> text 2</option>
           <option> text 3</option>
        </select>
      <button>submit<button>
    </form>

in data.php

<?php 
   $text = $_POST['text'];
   echo $text;
?>