I need a bit of help understanding what I should do here.
I have an .php page called view that has the following drop down form code in it.
$sql = "SELECT DISTINCT dept FROM sw_lic WHERE dept != ''"; // (1)
$result2 = mysql_query($sql);
echo "<form action='NB_sw_lic/filter_view.php?$nt' method='POST'>"; // (2)
echo "<select name='dept'>"; // (3)
while($nt=mysql_fetch_array($result2))
{
echo "<option value=$nt[dept]>$nt[dept]</option>";
}
echo "</select>";
echo "<input type='submit' name='submit' value='Submit'>";
I This automatically populates the dropdown menu with values from the MySQL database. What I would like to have happen is that when the user selects an option and clicks the select button, the option they selected is transmitted to another page called filtered_View.php that would then populate a table with all records that match that previous pages selection. Here is the code for filter_view.php
// get results from database
$result = mysql_query("SELECT * FROM sw_lic WHERE dept = $nt")
or die(mysql_error());
// display data in table
echo "<table border='1' cellpadding='10' background-color='#000066' color='#FFFFFF'>";
echo "<tr> <th>Username</th> <th>System Name</th> <th>Dept.</th> <th>Software Name</th> <th>Software Ver.</th> <th>Software Origin</th> <th>LIC Key</th> <th></th> <th></th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['username'] . '</td>';
echo '<td>' . $row['sysname'] . '</td>';
echo '<td>' . $row['dept'] . '</td>';
echo '<td>' . $row['sw_name'] . '</td>';
echo '<td>' . $row['sw_ver'] . '</td>';
echo '<td>' . $row['origin'] . '</td>';
echo '<td>' . $row['sw_key'] . '</td>';
echo '<td><a href="edit.php?sw_id=' . $row['sw_id'] . '">Edit</a></td>';
echo '<td><a href="delete.php?sw_id=' . $row['sw_id'] . '">Delete</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
I have no clue how to pass the variable from the dropdown menu to this page, can anyone help me out?
Thanks soo much in advance for your assistance.