le 19/09/2007 à 13:34
unlink()
désolé pour le double post…
Encore merci à tous pour votre aide précieuse ;-)
Encore merci à tous pour votre aide précieuse ;-)
<html>
<head>
<style type="text/css">
<!--
body {
background-color: #E5E5E5;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
-->
</style>
</head>
<body>
<?php
echo $_POST[numero]."<br><br>";
echo $_POST[parution]."<br><br>";
echo nl2br(stripslashes($_POST[contenu]))."<br><br>";
include ("../private/connexion.php");
function CopiePhoto() {
if($_FILES[image][size]>1) {
copy($_FILES[image][tmp_name], "images/".$_FILES[image][name]);
}// if
}
function SupprimerPhoto($id) {
require ("../private/connexion.php");
$requete = "SELECT * From news WHERE id='$_GET[id]'";
$resultat = mysql_query ($requete, $connexion) or die('Erreur SQL !<br />'.$requete.'<br />'.mysql_error());
while ($data = mysql_fetch_array ($resultat)) {
unlink ("images/".$data[image]);
}
}
include ("miseEnForme.php");
if($_GET[action] == "delete") {
$supprimer = "DELETE FROM news WHERE id=$_GET[id]";
mysql_query ($supprimer, $connexion);
}
elseif ($_GET[action]=="update") {
CopiePhoto();
$modifier = "UPDATE news SET id='$_GET[id]', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."' WHERE id='$_GET[id]'";
mysql_query ($modifier, $connexion);
}
elseif ($_GET[action]=="insert") {
CopiePhoto();
$ajouter = "INSERT news SET id='', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."'";
mysql_query ($ajouter, $connexion);
}
elseif ($_GET[action] == "deletePhoto") {
SupprimerPhoto($id);
}
$requete = "SELECT * From news order by id DESC";
$resultat = mysql_query ($requete, $connexion);
?>
<table border=1 width=600>
<?
while ($data = mysql_fetch_row ($resultat)) {
list ($id, $numero, $parution, $contenu, $image) = $data;
echo "<tr><td valign='top' width='325' border='1'>";
echo "<h3>".$numero.' - '.$parution."</h3>";
echo resumeTexte($contenu)."<br><br>";
echo "</td><td valign='center' width='200'>";
echo "<div align='center'><img src='images/".$image."' width='140' height='200'></div><br>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=delete' onclick='return confirm (\"Supprimer cet enregistrement ?\");'><img src='images/supprimer.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='form_news.php?id=$id&action=update'><img src='images/modifier.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=deletePhoto'>Supprimer la photo</a>";
echo "</td></tr>";
}
?>
</td><td><a href='form_news.php?action=insert'><img src='images/ajouter.gif'></a></td></tr>
</table>
</body>
</html>
<html>
<head>
<style type="text/css">
<!--
body {
background-color: #E5E5E5;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
-->
</style>
</head>
<body>
<?php
echo $_POST[numero]."<br><br>";
echo $_POST[parution]."<br><br>";
echo nl2br(stripslashes($_POST[contenu]))."<br><br>";
include ("connexion.php");
$connexion = mysql_connect($host, $user, $pass);
$base = "mabase";
mysql_select_db($base, $connexion);
function CopiePhoto() {
if($_FILES[image][size]>1) {
copy($_FILES[image][tmp_name], "images/".$_FILES[image][name]);
}// if
}
function SupprimerPhoto($id) {
$requete = "SELECT * FROM news WHERE id=$_GET[id]";
$resultat = mysql_query ($requete, $connexion);
while ($data = mysql_fetch_array ($resultat)) {
unlink ("images/".$data[image]);
}
}
include ("miseEnForme.php");
if($_GET[action] == "delete") {
$supprimer = "DELETE FROM news WHERE id=$_GET[id]";
mysql_query ($supprimer, $connexion);
}
elseif ($_GET[action]=="update") {
CopiePhoto();
$modifier = "UPDATE news SET id='$_GET[id]', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."' WHERE id='$_GET[id]'";
mysql_query ($modifier, $connexion);
}
elseif ($_GET[action]=="insert") {
CopiePhoto();
$ajouter = "INSERT news SET id='', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."'";
mysql_query ($ajouter, $connexion);
}
elseif ($_GET[action] == "deletePhoto") {
SupprimerPhoto($id);
}
$requete = "SELECT * From news order by id DESC";
$resultat = mysql_query ($requete, $connexion);
?>
<table border=1 width=600>
<?
while ($data = mysql_fetch_row ($resultat)) {
list ($id, $numero, $parution, $contenu, $image) = $data;
echo "<tr><td valign='top' width='325' border='1'>";
echo "<h3>".$numero.' - '.$parution."</h3>";
echo resumeTexte($contenu)."<br><br>";
echo "</td><td valign='center' width='200'>";
echo "<div align='center'><img src='images/".$image."' width='140' height='200'></div><br>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=delete' onclick='return confirm (\"Supprimer cet enregistrement ?\");'><img src='images/supprimer.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='form_news.php?id=$id&action=update'><img src='images/modifier.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=deletePhoto'>Supprimer la photo</a>";
echo "</td></tr>";
}
?>
</td><td><a href='form_news.php?action=insert'><img src='images/ajouter.gif'></a></td></tr>
</table>
</body>
</html>
<html>
<head>
<style type="text/css">
<!--
body {
background-color: #E5E5E5;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
-->
</style>
</head>
<body>
<?php
echo $_POST[numero]."<br><br>";
echo $_POST[parution]."<br><br>";
echo nl2br(stripslashes($_POST[contenu]))."<br><br>";
echo "<br><br>";
function CopiePhoto() {
if($_FILES[image][size]>1) {
copy($_FILES[image][tmp_name], "images/".$_FILES[image][name]);
}// if
}
function SupprimerPhoto() {
$requete = "SELECT * FROM news WHERE id=$_GET[id]";
$resultat = mysql_query ($requete, $connexion);
while ($data = mysql_fetch_array ($resultat)) {
unlink ("images/".$data[image]);
}
}
include ("connexion.php");
$connexion = mysql_connect($host, $user, $pass);
$base = "mabase";
mysql_select_db($base, $connexion);
include ("miseEnForme.php");
if($_GET[action] == "delete") {
$supprimer = "DELETE FROM news WHERE id=$_GET[id]";
mysql_query ($supprimer, $connexion);
}
elseif ($_GET[action]=="update") {
CopiePhoto();
$modifier = "UPDATE news SET id='$_GET[id]', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."' WHERE id='$_GET[id]'";
mysql_query ($modifier, $connexion);
}
elseif ($_GET[action]=="insert") {
CopiePhoto();
$ajouter = "INSERT news SET id='', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."'";
mysql_query ($ajouter, $connexion);
}
elseif ($_GET[action] == "deletePhoto") {
SupprimerPhoto();
}
$requete = "SELECT * From news order by id DESC";
$resultat = mysql_query ($requete, $connexion);
?>
<table border=1 width=600>
<?
while ($data = mysql_fetch_row ($resultat)) {
list ($id, $numero, $parution, $contenu, $image) = $data;
echo "<tr><td valign='top' width='325' border='1'>";
echo "<h3>".$numero.' - '.$parution."</h3>";
echo resumeTexte($contenu)."<br><br>";
echo "</td><td valign='center' width='200'>";
echo "<div align='center'><img src='images/".$image."' width='140' height='200'></div><br>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=delete' onclick='return confirm (\"Supprimer cet enregistrement ?\");'><img src='images/supprimer.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='form_news.php?id=$id&action=update'><img src='images/modifier.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=deletePhoto'>Supprimer la photo</a>";
echo "</td></tr>";
}
?>
</td><td><a href='form_news.php?action=insert'><img src='images/ajouter.gif'></a></td></tr>
</table>
</body>
</html>
$requete = 'SELECT DISTINCT image FROM ta_table WHERE id="'.$id.'" ;
Chargement en cours