PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Ok, so hard coded in the html means hardcoded in the PHP. That is OK (for now, you'll probably want to loosed that up later on).
So when the form is posted, you need to grab each member of the POST array and validate it (make sure it belongs and that it contains the type of data you expect and that is not malicious), then you present that to your database as a query.
Well, you need to make sure that the passed data is what you expect it to be. What if someone saved the source of your form and changed values, then passed it back to your server? How would you catch that? What happens if the rlsdate was passed as 'gobbledygook'?
I try to keep anything that gives users a choice in my database. For me, it makes it easier to check and validate because you control the source outside of the hard coded HTML.
Basically you would do it the same way as any other content in the site. SELECTS get the form field information and validation takes place using the same result array.
Basically like the sample code I posted. Select it, then iterate it into an array. Then loop the array to populate the select lists (and use that same array as your validation source).
<?php
$_POST = array(
'rlsdate' => 'last30', 'last60', 'last90', 'last6mth', 'lastyr', 'overayr'
'avgrating' => '4ormore', '3ormore', '2ormore', '1ormore'
'genre' => 'action', 'animation', 'kids', 'comedy', 'docu', 'drama', 'horror', 'musical', 'scifi', 'thriller'
)
;
//Determin if user has selected a form value
if (isset($_POST['rlsdate' or 'avgrating' or 'genre'])) {
//Perform SQL Query using Field value selected
}
;
else
{
//Perform SQL Query to display all results
}
;
?>
Remember, $_POST comes from the data in forms. You don't really want to mess with it the way you are in your code. Make arrays of the items that you are wanting to fill the select lists with. Then loop them to show them.