简体   繁体   中英

How to retrieve both form values and names in form of an array

I have a form with a selection tag. This form can post many options at a time. When ever I assign a variable to the selection name eg $name=$_POST['name']; It only echoes arrays of the form values and not the options. I want a situation where by a variable can be assigned to the value[] array and the name[] array separately so that they can be used in a php script to manipulate a database. I need your assistance. Thanks.

HTML

<select name="options">
  <option value="1">First</option>
  <option value="2">Second</option>
  <option value="3">Third</option>
</select>

PHP

$value = $_POST['options'];

$value will hold the value that you have selected

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM