I have no idea why this foreach it`s not running. When i post the article, only inserts once. Should make it at much as needed. Do you see any problem?
$array_produse = array();
for($i=1; $i<=8; $i++)
{
$gramaj = isset($_POST['image'.$i.'_gramaj']) ? $_POST['image'.$i.'_gramaj'] : '';
$pret = isset($_POST['image'.$i.'_pret']) ? $_POST['image'.$i.'_pret'] : '';
$array_produse[$i]['gramaj'] = $gramaj;
$array_produse[$i]['pret'] = $pret;
$array_produse[$i]['numar_produs'] = $i;
}
foreach($array_produse as $produs)
{
$wpdb->insert(
'produse',
array(
'id' => $post_id,
'pret' => $produs['pret'],
'gramaj' => $produs['gramaj'],
'numar_produs' => $produs['numar_produs']
));
}



var_dump($array_produse)before foreach and see what the output is – bungeshea Jan 17 at 23:08array(8) { [1]=> array(3) { ["gramaj"]=> string(1) "1" ["pret"]=> string(1) "1" ["numar_produs"]=> int(1) } [2]=> array(3) { ["gramaj"]=> string(1) "2" ["pret"]=> string(1) "2" ["numar_produs"]=> int(2) } [3]=> array(3) { ["gramaj"]=> string(1) "3" ["pret"]=> string(1) "3" ["numar_produs"]=> int(3) }– Iulian Bozeanu Jan 17 at 23:10$post_idfrom? – bungeshea Jan 17 at 23:13$post_id = $post->ID;– Iulian Bozeanu Jan 17 at 23:13idcolumn unique? What is your db table structure? – bungeshea Jan 17 at 23:14