Teddy Teddy - 1 year ago 123
PHP Question

How to get select value from another php file?

How to get

value from another php file.
Example :


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


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

as you can read above, how to get value from
and use it in

Answer Source

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>
<input type="submit" value="Submit the form"/>

then add $_GET on your data.php

$text = $_GET['text']
$sql= "SELECT column FROM table where $text='ABCDE'"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download