November 17, 201313 yr Just wonderedd if anyone can help I have a form with 2 arrays stored in it (1 as checkbox options and 1 as a select option) as following.. <form class="indexSearch" action="search.php" method="post"> <ul class="indexSearchIndustryList"> <li> <input type="checkbox" value="1" name="industryList[]"><a href="#">Bathroom Fitting</a> </li> <li> <input type="checkbox" value="2" name="industryList[]"><a href="#">Bricklaying</a> </li> <li> <input type="checkbox" value="3" name="industryList[]"><a href="#">Carpentry</a> etc... <select class="indexSearchLocationList"> <option value="a" name="locationList[]">Anywhere in London </option> <option value="b" name="locationList[]">Barking and Dagenham </option> <option value="c" name="locationList[]">Barnet </option> etc.... the problem im having is when I submit the form only 1 array (industry list is being posted although im posting them both the same way. <?php $industryListResults = $_POST['industryList']; $locationListResults = $_POST['locationList']; $results = mysqli_query($con,"SELECT * FROM currentListings WHERE industry = '$[industryListResults]' AND location = '$[locationListResults]' "); while($row = mysqli_fetch_array($results)) { echo $row['industry']; echo "<br>"; } mysqli_close($con); ?> </div> the error I keep getting is Undefined index: locationList in C:\David\Wamp\wamp\www\training_and_apprenticeships\search.php on line 15 does anyone have any ideas why this might be happening? any help would be really appreciated
November 17, 201313 yr You don't provide a name for each <option> you only provide a name for the select tag like below. The option values will be pulled as needed <select class="indexSearchLocationList" name="locationList"> <option value="a" >Anywhere in London </option> <option value="b" >Barking and Dagenham </option> <option value="c">Barnet </option>
Create an account or sign in to comment