voila tout est op n'oubliez pas de renomer votre page dans le header en fin de requete sql
je vous file ma base en format sql que vous pouvez importer dans phpmyadmin a vous de changer le path des image et réinitialiser les id
il faudra aussi importer le jquery-1.4a2.min.js que je dois encore peaufiner
et bien entendu il faudra au prealable créer une page pour le premier insert des images
enjoy!!! merci à alsacréations forum et leur participants pour le coup de pouce
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Document sans titre</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="scripts/jquery-1.4a2.min.js"type="text/javascript"></script>
<script>
var blank="img/log_pas_image.png";
function readURL(input) {
//alert(input.value);//donne le nom de la photo en cours d'upload
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
if(input.id==0){
$('#img_prev0')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==1)
{
$('#img_prev1')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==2)
{
$('#img_prev2')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==3)
{
$('#img_prev3')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==4)
{
$('#img_prev4')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==5)
{
$('#img_prev5')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==6)
{
$('#img_prev6')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==7)
{
$('#img_prev7')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==8)
{
$('#img_prev8')
.attr('src', e.target.result)
.height(100);
}
else if(input.id==9)
{
$('#img_prev9')
.attr('src', e.target.result)
.height(100);
}
};
reader.readAsDataURL(input.files[0]);
}
else {
var img = input.value;
$('#img_prev').attr('src',img).height(100);
}
$("#x").show().css("margin-right","10px");
}
$(document).ready(function() {
$("#x").click(function() {
$("#img_prev").attr("src",blank);
$("#x").hide();
});
});
</script>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
#x { display:none; position:relative; z-index:200; float:right}
#previewPane { display: inline-block; }
</style>
</head>
<body>
<?php
$idgite="1";
// on se connecte à la base de données
if( $_SERVER['SERVER_NAME'] == '127.0.0.1' or $_SERVER['SERVER_NAME'] == 'localhost' )
{
$nom_du_serveur="127.0.0.1"; $nom_de_la_base="abbaye"; $nom_utilisateur="root"; $passe="";
mysql_connect( $nom_du_serveur, $nom_utilisateur, $passe);
mysql_select_db( $nom_de_la_base );
}else{
$nom_du_serveur="xxxxx"; $nom_utilisateur="xxxx"; $nom_de_la_base="espelidoabbaye"; $passe="xxxxx";
mysql_connect( $nom_du_serveur, $nom_utilisateur, $passe);
mysql_select_db( $nom_de_la_base );
}
mysql_connect("$nom_du_serveur","$nom_utilisateur","$passe");
mysql_select_db("$nom_de_la_base") or die('Impossible de sélectionner une base de donnée. Assurez vous d\'avoir correctement remplit les données du fichier connexion_bd.php.');
mysql_query("SET NAMES UTF8");
$requeteSQL= mysql_query("SELECT * FROM photo WHERE idgite='".mysql_real_escape_string($idgite)."' ORDER BY photo.idordre ASC");
if(mysql_num_rows($requeteSQL) == 0)
{
echo '<p>Pas de gîte pour le moment!</p>';
}
//Si la table contient des trucs, on affiche les données
else {
echo'<form style="float:right;" action="" method="post" enctype="multipart/form-data">';
while($affiche = mysql_fetch_array($requeteSQL))
{
echo '<input id="'.$affiche['idordre'].'" class="file" type="file" name="pictures[]" onchange="readURL(this);"/><br/>
<span id="x">[X]</span>
<span id="previewPane'.$affiche['idordre'].'">
<img style="width:200px;" id="img_prev'.$affiche['idordre'].'" src="images/'.$affiche['photo'].'" alt="your image" />
<input type="hidden" name="'.$affiche['idordre'].'" value="'.$affiche['id'].'"/>
</span><br/>';
}
echo '<input type="submit" name="Send" value="fait peter" /></form>';
}
if(isset($_POST['Send'])){
//on nettoie la fin du $_POST[ poluer par send
$conte=$_POST;
$conte_prov = array_pop($conte);
$tab["conteur"]= $conte;
print_r($conte);
echo '<br/>';
$image=$_FILES;
array_push($image["pictures"],$tab);
foreach ($image["pictures"]["error"] as $key => $error ) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $image["pictures"]["tmp_name"][$key];
$name[$key] = $image["pictures"]["name"][$key];
$photo=$name[$key];
move_uploaded_file($tmp_name, "images/".$name[$key]);
}}
$size = sizeof($image['pictures']['name']); //me retourne 6
echo $size;
echo '<br/>';
for($i = 0; $i < $size ; $i++){
// print_r( $image['pictures']['name'][$i] . '<br/> ');
$photos=$image['pictures']['name'][$i];
echo $photos. '<br/> ';
// print_r( $image['pictures']['type'][$i] . '<br/> ');
// print_r( $image['pictures']['tmp_name'][$i] . '<br/> ');
// print_r( $image['pictures']['error'][$i] . '<br/> ');
// print_r( $image['pictures']['size'][$i] . '<br/> ');
// print_r( $image['pictures']['0']['conteur'][$i] . '<br/> ');
$id=$image['pictures']['0']['conteur'][$i];
echo $id. '<br/> ';
// print_r($i. '<br/> ');
$idordre=$i;
// on enregistre les données
$result = mysql_query(" UPDATE photo SET idgite='".mysql_real_escape_string($idgite)."', photo='".mysql_real_escape_string($photos)."', idordre='".mysql_real_escape_string($idordre)."' WHERE id = '".mysql_real_escape_string($id)."'");
//Si il y a une erreur, on crie ^^
if (!$result) {
die('Requête invalide : ' . mysql_error());
}
else{
//Si tout est ok, on informe le webmaster
$message_ok = '<div class="erreur"><a name="ok"></a><b>Page modifiée avec succès!</b></div>';
header("Location: multimageazi.php");
}
}
}
?>
</body>
</html>
la base
-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Client: localhost
-- Généré le : Mar 29 Mai 2012 à 17:27
-- Version du serveur: 5.5.16
-- Version de PHP: 5.3.8
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Base de données: `abbaye`
--
-- --------------------------------------------------------
--
-- Structure de la table `photo`
--
CREATE TABLE IF NOT EXISTS `photo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`idgite` int(11) NOT NULL,
`photo` varchar(100) NOT NULL,
`idordre` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1864 ;
--
-- Contenu de la table `photo`
--
INSERT INTO `photo` (`id`, `idgite`, `photo`, `idordre`) VALUES
(1863, 1, 'slideHomeplaisir.jpg', 0),
(1862, 1, 'slideHome_loisirs.jpg', 1),
(1860, 1, 'slideHome_bien_etre.jpg', 2),
(1861, 1, 'slideHome_paysages.jpg', 3),
(1853, 1, 'slideBienEtre_hammam.jpg', 4),
(1854, 1, 'slideHome_confort.jpg', 5),
(1855, 1, 'lideChambresdHotes_Frais.jpg', 6),
(1856, 1, 'slideBienEtre_jacuzzi.jpg', 7),
(1857, 1, 'slideHome_lumieres.jpg', 8),
(1858, 1, 'slideChambresdHotes_ptitDej.jpg', 9);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;