Php insertion d'un array

Alix -  
 o_edo1 -
Bonjour à tous,

Comme dans le titre j'ai un tableau array.


$tab = array()

dans lequel il y a

[0] => toto
[1] => titi
[2] => tata


Est il possible de réaliser un insert avec les données du tableau genre :

$sql ="INSERT INTO fiche (id,id_fiche,nom) VALUES('',[0],'toto')";
$sql ="INSERT INTO fiche (id,id_fiche,nom) VALUES('',[1],'titi')";
$sql ="INSERT INTO fiche (id,id_fiche,nom) VALUES('',[2],'tata')";


Avec une boucle?

Merci d'avance

1 réponse

  1. o_edo1
     
    $tableau = array(
    array(
    'fiche_id' => 1,
    'nom' =>'toto'
    ),
    array(
    'fiche_id' => 2,
    'nom' => 'titi'
    )
    );
    foreach($tableau as $el){
    $db->query( "INSERT INTO fiche (id,id_fiche,nom) VALUES('',$el['fiche_id'],$el['nom'])");
    }
    0