an array called "works". looks this:
array ( [type] => array ( [0] => 1 [1] => 5 ) [description] => array ( [0] => 2 [1] => 6 ) [hours] => array ( [0] => 3 [1] => 7 ) [amount] => array ( [0] => 4 [1] => 8 ) )
i need send values database (mysql) in 2 iterations. like:
instert `works` (`type`, `decsripion`, `hours`, `amount`) values (works[type][0], works[decsription][0], works[hours][0], works[amount][0]); instert `works` (`type`, `decsripion`, `hours`, `amount`) values (works[type][1], works[decsription][1], works[hours][1], works[amount][1]);
for($i=0; $i<count($works['type']); $i++) { $query = "insert `works` (`type`, `decsripion`, `hours`, `amount`) values ('{works[type][$i]}', '{works[description][$i]}', '{works[hours][$i]}', '{works[amount][$i]}')"; mysql_query($query); }
that provided have connected , selected database. there better ways of doing depends on framework using. example, might want escape these values before trying insert them database.