par
ulfhamir » 05 mai 2010, 13:53
marche pas!
Je pense qu'il faudrait plutôt que je procède comme ça:
Code : Tout sélectionner
if(!empty($_POST['nom']) )
{ $nom = $_POST['nom'];
$nomarray = preg_split('/,/', $nom, -1, PREG_SPLIT_NO_EMPTY);
$nomarray = preg_split('/undefined/', $nom, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['large']))
{$width = $_POST['large'];
$widtharray = preg_split('/,/', $width, -1, PREG_SPLIT_NO_EMPTY);
$widtharray = preg_split('/undefined/', $width, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['haut']))
{ $height = $_POST['haut'];
$heightarray = preg_split('/,/', $height, -1, PREG_SPLIT_NO_EMPTY);
$heightarray = preg_split('/undefined/', $height, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['positionX']))
{$posx = $_POST['positionX'];
$posxarray = preg_split('/,/', $posx, -1, PREG_SPLIT_NO_EMPTY);
$posxarray = preg_split('/undefined/', $posx, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['positionY']))
{ $posy = $_POST['positionY'];
$posyarray = preg_split('/,/', $posy, -1, PREG_SPLIT_NO_EMPTY);
$posyarray = preg_split('/undefined/', $posy, -1, PREG_SPLIT_NO_EMPTY);
}
$connect=mysql_connect(DB_HOST,DB_LOGIN,DB_PASS) or die ('erreur de connexion');
mysql_select_db(DB_BDD) or die ('erreur de connexion à la base');
for ($i=0;$i<count($nomarray);$i++)
{
$requeteinsert = 'INSERT INTO preview(url,lienimage,nom,width,height,posX,posY) VALUES(\''.$url.'\',\''.$lienimage.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\')';
$result = mysql_query($requeteinsert,$connect);
}
$?jesais pas car comme je voudrais mettre une variable de chaque tableau par ligne,si je fais $nomarray[$i],il me met tout le contenu du tableaux(normal).Comment faire pour qu'il y ai autant de ligne que de valeur dans le tableau tout en n'insérant qu'une variable par ligne?
marche pas!
Je pense qu'il faudrait plutôt que je procède comme ça:
[code]if(!empty($_POST['nom']) )
{ $nom = $_POST['nom'];
$nomarray = preg_split('/,/', $nom, -1, PREG_SPLIT_NO_EMPTY);
$nomarray = preg_split('/undefined/', $nom, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['large']))
{$width = $_POST['large'];
$widtharray = preg_split('/,/', $width, -1, PREG_SPLIT_NO_EMPTY);
$widtharray = preg_split('/undefined/', $width, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['haut']))
{ $height = $_POST['haut'];
$heightarray = preg_split('/,/', $height, -1, PREG_SPLIT_NO_EMPTY);
$heightarray = preg_split('/undefined/', $height, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['positionX']))
{$posx = $_POST['positionX'];
$posxarray = preg_split('/,/', $posx, -1, PREG_SPLIT_NO_EMPTY);
$posxarray = preg_split('/undefined/', $posx, -1, PREG_SPLIT_NO_EMPTY);
}
if(!empty($_POST['positionY']))
{ $posy = $_POST['positionY'];
$posyarray = preg_split('/,/', $posy, -1, PREG_SPLIT_NO_EMPTY);
$posyarray = preg_split('/undefined/', $posy, -1, PREG_SPLIT_NO_EMPTY);
}
$connect=mysql_connect(DB_HOST,DB_LOGIN,DB_PASS) or die ('erreur de connexion');
mysql_select_db(DB_BDD) or die ('erreur de connexion à la base');
for ($i=0;$i<count($nomarray);$i++)
{
$requeteinsert = 'INSERT INTO preview(url,lienimage,nom,width,height,posX,posY) VALUES(\''.$url.'\',\''.$lienimage.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\',\''.$?jesaispas.'\')';
$result = mysql_query($requeteinsert,$connect);
}[/code]
$?jesais pas car comme je voudrais mettre une variable de chaque tableau par ligne,si je fais $nomarray[$i],il me met tout le contenu du tableaux(normal).Comment faire pour qu'il y ai autant de ligne que de valeur dans le tableau tout en n'insérant qu'une variable par ligne?