I have 2 frames, and a MySQL table full of elements.
The first frame has a dropdown menu and a submit button. The values (total 15) of dropdown list are taken from a MySQL database with the query SELECT DISTINCT (table_column) table_name
.
<!DOCTYPE html>
<html>
<body>
<form method="post">
<?php
include_once "CONNECT_TO_DB_SCRIPT.php";
$query_ak = 'SELECT DISTINCT (column_name) FROM table_name';
$result = mysql_query($query_ak) or die(mysql_error());
?>
<select name="exa">
<?php
while ($row = mysql_fetch_assoc($result)) {
echo '<option value="'.$row['ak_ex'].'">'.$row['ak_ex'].'</option>';
}
?>
</select>
<input type="submit" value="GO!" name="go"/>
</form>
</body>
</html>
So now I want in the second frame to check if we select a value of the dropdown list to show the equivalent part of MySQL table where the values of a certain column_name are the same with the value I submited in dropdown menu.
Example: SELECT * FROM table_name where column_name= value_of_dropdown_menu.
I've tried this but it didn't work:
<?php
include_once "CONNECT_TO_DB_script.php";
$query_ak='SELECT DISTINCT (column_name) FROM table_name';
$result_ak = mysql_query ($query_ak) or die (mysql_error());
if (isset($_POST['go'])) { //checks if submit button has a value or it is NULL
while ($row = mysqli_fetch_assoc($result_ak)) {
if ($_POST["exa"] == "$row['ak_ex']") {
$query = "SELECT * FROM table_name where column_name='.$row['ak_ex'].'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
…
close connection
?>