It is necessary to transfer to the server table values ​​in four columns. the number of lines is not known in advance; all lines have different id, but inside each standard name. How is all this miracle better to transfer to the server?

<tbody id="ntbody"> <tr id="0"> <td>Цвет<select name="color" id=""> <option value=""></option> <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> </select></td> <td>Размер<select name="size" id=""> <option value=""></option> <option value="1">1jgwbz</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select></td> <td>Артикул<input type="text" name="art"></td> <td>Количество<input type="text" name="count" style="width:50px;" value="0"></td> </tr> </tbody> 

From all this, I would like to get on the server a type

 Array ( [0] => Array ( [color] => 1 [size] => xl [art] => 123 [count] => 10 ) [1] => Array ( [color] => 1 [size] => xl [art] => 123 [count] => 10 ) [2] => Array ( [color] => 1 [size] => xl [art] => 123 [count] => 10 ) [3] => Array ( [color] => 1 [size] => xl [art] => 123 [count] => 10 ) ) 

tried jquery:

 $.ajax({url: 'echo.php', data:$('#ntbody select, #ntbody input', success: alert(html))}); 

In echo.php:

 <?php print_r($_GET);?> 

But this is the first line (((

What do you advise to do?

  • It was decided if it would be useful to anyone: left the old js, php replaced by: function crazy () {$ uri = $ _ SERVER ['REQUEST_URI']; $ uri = explode ("?", $ uri); $ uri = explode ("&", $ uri [1]); foreach ($ uri as $ ur) {$ h = explode ("=", $ ur); $ array [$ h [0]] [] = urldecode ($ h [1]); } return $ array; } print_r (crazy ()); Although it was much faster and more convenient to send the whole thing from the page in Json, but it was not there ... Good luck to all. - jaggman
  • Redid easier <pre> function crazy () {$ uri = $ _ SERVER ['QUERY_STRING']; $ uri = explode ("&", $ uri); foreach ($ uri as $ ur) {$ h = explode ("=", $ ur); $ array [$ h [0]] [] = urldecode ($ h [1]); } return $ array; } </ pre> - jaggman
  • @jaggmanm all the data that you explod , it already lies in the $ _GET array (and should be in $ _POST). - etki

0