Skip to content

Instantly share code, notes, and snippets.

@abdulawal39
Last active October 1, 2020 17:21
Show Gist options
  • Save abdulawal39/928bf868834c9accb3b1 to your computer and use it in GitHub Desktop.
Save abdulawal39/928bf868834c9accb3b1 to your computer and use it in GitHub Desktop.
Extract Values from Multi Select DropDown with PHP
<?php
/**
* File Name: extract-data-from-multi-select.php
* Description: A Simple way to Extract Data from a Multi Select Input and Store in a variable with spearating each values with comma.
* Author: Abdul Awal Uzzal
* Author Url: abdulawal.com
* Article: http://themencode.com/?p=435
*/
if(isset($_POST['select_name'])){ // select_name will be replaced with your input filed name
$getInput = $_POST['select_name']; // select_name will be replaced with your input filed name
$selectedOption = "";
foreach ($getInput as $option => $value) {
$selectedOption .= $value.','; // I am separating Values with a comma (,) so that I can extract data using explode()
}
echo $selectedOption;
}
?>
<form action="" method="POST">
<select name="select_name[]" id="" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<input type="submit">
</form>
@abdulawal39
Copy link
Author

can be run over python? Do you make tutorial videos as well? if you do, kindly share the link, please. I have to scrape data from a website having multiple dropdowns and each dropdown has time-series data ( there are 8 tabs on year, Element 1 .. element 7) Kindly help

Its for php, There might be solutions for python somewhere else but not this one :)

@SrHell7
Copy link

SrHell7 commented Oct 1, 2020

Nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment