php - Insert a value by row and column based using jQuery -


i have array rows , columns values corresponding rows , columns. need insert values table.

the array have below:

array (      [cols] => array         (             [0] => c1             [1] => c2             [2] => c3         )      [rows] => array         (             [0] => r1             [1] => r2             [2] => r3             [3] => r4         )      [name] => array         (             [0] => 1             [1] => 2             [2] => 3             [3] => 1             [4] => 2             [5] => 3             [6] => 1             [7] => 2             [8] => 3             [9] => 1             [10] => 2             [11] => 3         )  ) 

the table structure need is:

id | row | column | value -------------------------- 1  | r1  |  c1    |  1 2  | r1  |  c2    |  2 3  | r1  |  c3    |  3 4  | r2  |  c1    |  1 5  | r2  |  c2    |  2 6  | r2  |  c3    |  3 7  | r3  |  c1    |  1 8  | r3  |  c2    |  2 9  | r3  |  c3    |  3 etc.. 

if try in , each loop looping continuously looping number of times..

please me rid out problem

you can try this:

$i = 0; $table = array();  foreach ( $array['rows'] $row ) {     foreach ( $array['cols'] $col ) {         $table['id'] = $i + 1;         $table['row'] = $row;         $table['column'] = $col;         $table['value'] = $array['name'][$i];     }  } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -