从PHP下拉列表中获取选定的值

问题描述:

I have a drop-down button in my page and it is defined in html. What I need is like when I go to next page I need to use this selected value there . I dont know how is it possible . I tried searching about it and I am not getting anything . I am new in this field . Can some please tell me how to make it possible. I am attaching my code part in here .

<!DOCTYPE html>
<html>
<head>
    <title>Demo</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="Home">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="bootstrap.css">


</head>

    <div class="container">
<select class="form-control" >
    <option value="ah">1</option>
    <option value="aa">2</option>
    <option value="aet">3</option>
    <option value="amt">4</option>

</select>
<br>
<?php 


        echo "<form action=log_file.php method=GET>";
        echo "<td>" ." <input type = text class = form-control name = admin_search placeholder = 'Enter  Name'>". "</td>";
        echo"<br>";
            echo "<td>" ."<input class=btn type=submit value=select". "></td>";


        echo "</form>";

        ?>
 </body>

You should put select block (with a name) in the form block.

echo "<form action=log_file.php method=GET>";
echo "<td>" ." <input type = text class = form-control name = admin_search placeholder = 'Enter  Name'>". "</td>";

echo '<td><select class="form-control" name="select-val">
    <option value="ah">1</option>
    <option value="aa">2</option>
    <option value="aet">3</option>
    <option value="amt">4</option>
</select></td>';
echo "<br>";
echo "<td>" ."<input class=btn type=submit value=select". "></td>";


echo "</form>";

And in the next page you can get selected value using

echo $_GET["select-val"];

place the select inside the form and assign a name to it. on the next page, use $_GET['nameOfTheSelect']

But why are you echo-ing the form with php?