Home › Forums › Back End › Drop Down Executes Query On Post? › Reply To: Drop Down Executes Query On Post?
May 19, 2014 at 8:44 pm
#170644
Participant
Updated code (only ouputs on record) :
$result = mysql_connect($Host, $User, $Password);
if(isset($_POST['Submit'])){
if($_POST['value'] == '1') {
// query to get all 1 star ratings
$query = mysql_query("SELECT * FROM films WHERE genre='action' AND rating='1'");
}
elseif($_POST['value'] == '2') {
// query to get all 2 star ratings
$query = mysql_query("SELECT * FROM films WHERE genre='action' AND rating='2'");
}
elseif($_POST['value'] == '3') {
// query to get all 3 star ratings
$query = mysql_query("SELECT * FROM films WHERE genre='action' AND rating='3'");
}
elseif($_POST['value'] == '4') {
// query to get all 4 star ratings
$query = mysql_query("SELECT * FROM films WHERE genre='action' AND rating='4'");
}
elseif($_POST['value'] == '5') {
// query to get all 5 star ratings
$query = mysql_query("SELECT * FROM films WHERE genre='action' AND rating='5'");
}
WHILE($row = mysql_fetch_array($query)){
$title = $row['title'];
$studio = $row['studio'];
$language = $row['language'];
$certification = $row['certification'];
The rest of the code is as previous. I had to remove the [] above as it outputs Array – literally it displayed array.