Bonjour. bonjour.

Voilà j ai un petit problème avec un script d'upload.

En fait tout fonctionne sauf, que pour mon image deux qui ne s affiche pas.
Je ne comprend pas du tout car tout semble correct

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
if ((isset($_POST["add_img"])) && ($_POST["add_img"] == "1")) {
	if($HTTP_POST_FILES['img']['name']!=''){
		if($_POST['img_main']==1){$img_main=1;}else{$img_main=0;}
		$nom_final=upload_img($id, $HTTP_POST_FILES['img']['name'], $HTTP_POST_FILES['img']['tmp_name']);
		//upload l'image et retourn son nom
		$updateSQL = "INSERT INTO img (id_link, img, statut, principale) Values (1, '$nom_final', 0, ".$img_main.")";
		$Result1 = mysql_query($updateSQL) or die(mysql_error());
	}
}
 
//Supprime une photo
if ($delimg!='') {
	$updateSQL = "DELETE FROM img WHERE id_link=$id and statut=0 and img='$delimg'";
	$Result1 = mysql_query($updateSQL) or die(mysql_error());
	unlink ('img/'.$delimg);
}
 
$query_img = "SELECT * FROM img where id_link='$id' and statut=0 ORDER BY id desc, id";
$query_img = mysql_query($query_img) or die(mysql_error());
$i=0;
$img=array(0,1,2,3);
 
while($row_query_img = mysql_fetch_array($query_img)){
	$img[$i]=$row_query_img['img'];
	$i++;
}
 
?>
 
<div>
 
<?php
if($img[0]!=0){
echo "Photo 1";
echo "<br />";
echo "<img src=\"img/$img[0]\" width=90 height=75 />";
echo "<br />";
echo "<a href=\"index.php?delimg=$img[0]&id=$id\"><font color=\"#333c86\"><b>Supprimer</b></font></a><br />";
}
 
if($img[1]!=1){
echo "Photo 2";
echo "<br />";
echo "<img src=\"img/$img[1]\" width=90 height=75 />";
echo "<br />";
echo "<a href=\"index.php?delimg=$img[1]&id=$id\"><font color=\"#333c86\"><b>Supprimer</b></font></a><br />";
}
 
if($img[2]!=2){
echo "Photo 3";
echo "<br />";
echo "<img src=\"img/$img[2]\" width=90 height=75 />";
echo "<br />";
echo "<a href=\"index.php?delimg=$img[2]&id=$id\"><font color=\"#333c86\"><b>Supprimer</b></font></a><br />";
}
 
if($img[3]!=3){
echo "Photo 4";
echo "<br />";
echo "<img src=\"img/$img[3]\" width=90 height=75 />";
echo "<br />";
echo "<a href=\"index.php?delimg=$img[3]&id=$id\"><font color=\"#333c86\"><b>Supprimer</b></font></a><br />";
}
?>
</div>
Voici mon url de test. N'hésitez pas à tester aussi pour vous faire une idée, mais attention a bien revenir sur cette url si vous supprimez des images, car le script n'est encore pas finalisé
http://www.cqfd.ch/www/upload_test/index.php?id=1

D'autre part on peut voir que mon tableau est fait seulement pour 4 images, comment pourrais-je procéder pour que l'on ne soit pas limité ?

Merci d'avance