Hello, I am using 2 drop down menus which pull their options from a database. Once the user selects a language and then a product a list of available pdf's are displayed. However the form resets it self. How can I set this up so the products for the language selected stays. I was thinking about using a session but im not sure how to go about that when dealing with pulling data from MySQL
here is the code i have thanks!
<?php
$query = "SELECT DISTINCT language FROM pdf_reference";
$pull = mysql_query($query);
while($row = mysql_fetch_array($pull)) {
print '<option>' . $row['language'] . '</option>';
}
?>
</select><br />
<input type="submit" name="submit" value="Next >>" />
</form>
<form method="post" action="http://localhost/pdf/index.php">
<select name="product" >
<?php
if (isset($_POST['submit'])) {
$language = $_POST['language'];
$product = "SELECT DISTINCT product FROM pdf_reference WHERE language='$language'";
$proquery = mysql_query($product);
?>
<?php
while($pro = mysql_fetch_array($proquery)) {
print '<option>' . $pro['product'] . '</option>';
}
}
?>
</select><br />
<input type="submit" name="viewpdfs" value="View PDFs" />
</form>
<?php
if (isset($_POST['viewpdfs'])) {
$product = $_POST['product'];
$product1 = "SELECT file_name, description FROM pdf_reference WHERE product='$product'";
$proquery1 = mysql_query($product1);
echo "you selected $product<br />";
while($desc = mysql_fetch_array($proquery1)) {
print '<hr>
' . $desc['file_name'] . '<br />' . $desc['description'] . '<br />';
}
}
?>