Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

problem using select/option arrays

Featured Replies

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

 

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.