49803

html multi array in PHP post

Question:

<form> <input class="date-pick" type="text" value="2010/08/02" name="date" /> <table id="events_selection"> <tr> <td> <img src="/admin/ajax/image.php?filename=/media/immagini/danieledaniela/1.jpg&maxw=200" /> <select name="1"> <option value="0"> NESSUN EVENTO </option> <option value="5">anelli</option> <option value="8">ballo</option> <option value="6">cerimonia in chiesa</option> <option value="13">dettagli</option> <option value="9" selected="selected"><strong>festa</strong></option> <option value="4">gli sposi</option> <option value="1">la sposa</option> <option value="3">lancio del riso</option> <option value="2">lo sposo</option> <option value="11">preparazione sposa</option> <option value="10">preparazione sposo</option> <option value="7">ristorante</option> <option value="12">varie</option> </select> </td> <td> <img src="/admin/ajax/image.php?filename=/media/immagini/danieledaniela/30.jpg&maxw=200" /> <select name="31"> <option value="0"> NESSUN EVENTO </option> <option value="5">anelli</option> <option value="8">ballo</option> <option value="6">cerimonia in chiesa</option> <option value="13">dettagli</option> <option value="9">festa</option> <option value="4">gli sposi</option> <option value="1">la sposa</option> <option value="3">lancio del riso</option> <option value="2">lo sposo</option> <option value="11">preparazione sposa</option> <option value="10">preparazione sposo</option> <option value="7">ristorante</option> <option value="12">varie</option> </select> </td> </tr> </table> </form>​​​​​​​​

HI, in a situation like this (which is an example, there are many selects and other inputs) posting this form would give a $_POST like this

array { date => "2010/08/09" input1 => "bla" input3 => "bla2" //list of selection 1 => 2 2 => 4 3 => 5 //ends list of selection input 4 => "bla4" }

Can I directly from the HTML form put the <select>s in seperate array since they represent a grouped array?

array { date => "2010/08/09" input1 => "bla" input3 => "bla2" //list of selection array { 1 => 2 2 => 4 3 => 5 } //ends list of selection input 4 => "bla4" }

Thanks!

Answer1:

This:

<select name="selection[1]"> <option>1</option> <option>2</option> <option>3</option> </select> <select name="selection[2]"> <option>1</option> <option>2</option> <option>3</option> </select>

Would return:

'selection' => array(1 => 1, 2 => 1)

Guess that's what you're looking for? :-)

Recommend

  • no duplication in a C code [closed]
  • SCRIPT87: Invalid argument
  • firebase storage cors strange Behaviour
  • Is it possible to control programs with Javascript?
  • PHP file_exists() anomaly
  • MVVM: Image Bind Source from FileOpenPicker
  • Mysql - How to search for 26 records that each begins with the letter of the alphabet?
  • pyodbc doesn't report sql server error
  • Conversion from string “a” to type 'Boolean' is not valid
  • Array with custom indexes in Ionic2
  • Grails calculated field in SQL
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • Sort List of Strings By Version
  • htaccess add www if not subdomain, if subdomain remove www
  • azure media services - The request body is too large and exceeds the maximum permissible limit
  • JSON response opens as a file, but I can't access it with JavaScript
  • Set the selected item in dropdownlist in MVC3
  • jQuery .attr() and value
  • How to install a .deb file on a jailbroken iphone programmatically?
  • Handling un-mapped Rest path
  • Syntax for setting draggablecursor property in google maps api
  • Highlight one bar in a series in highcharts?
  • Getting last autonumber in access
  • Accessing IRQ description array within a module and displaying action names
  • Resize panoramic image to fixed size
  • How to check if every primary key value is being referenced as foreign key in another table
  • MySQL WHERE-condition in procedure ignored
  • Display Images one by one with next and previous functionality
  • ORA-29908: missing primary invocation for ancillary operator
  • Do I've to free mysql result after storing it?
  • How to get next/previous record number?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • A cron job substitute?
  • json Serialization in asp
  • How do you join a server to an Active Directory (domain)?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How does Linux kernel interrupt the application?
  • reshape alternating columns in less time and using less memory