mardi 24 mars 2015

PHP mySQL multiple dropdowns leading to same page?

I have a webpage with two drop-downs and one search bar. The dropdowns and search bars are all different programs and I'm including those files into my main webpage. The dropdown that I include first on my webpage, if I select an option and it works right based on the "form action". The second dropdown and the search bar also return the same results as if I was using the first dropdown (though their "form action" files are different). I tried changing the order and turns out it always defaults to the formaction of the first navigation bar)!!


Here is what I have included-



include_once("DropDownVendor.php");
include_once("DropDown.php");
include_once("searchbar.php");




Here is the form action for the first include(dropdown 1)-



echo "<form action='processformvendor.php' method='POST'> <select name = 'fieldname1'>";


Here is the query to bring results-



$query = "SELECT * FROM Deals WHERE vendor= \"{$_POST['fieldname1']}\"";




Here is the form action for the second include (dropdown2)-



echo "<form action='processform.php' method='POST'> <select name = 'fieldname'>";


Here is the query to bring results-



$query = "SELECT * FROM Deals WHERE dealcategory= \"{$_POST['fieldname']}\"";




Here is the form action for the second include (search bar)-



<center>

<form action="searchresults.php" method="get">
<input type = "text" name = "keywords" autocomplete = "on" placeholder = "Search for deals" size = "70" />
<input type = "submit" value = "search" /

Here is the query to bring results-
if(isset($_GET['keywords']))

{$keywords = $_GET['keywords']

$query = mysqli_query($conn,"SELECT * FROM Deals

WHERE

vendor LIKE '%$keywords%'

OR description LIKE '%$keywords%'");

Aucun commentaire:

Enregistrer un commentaire