Plusieurs photos

elpoueko -  
 elpoueko -
Bonjour,
j'aimerais pouvoir afficher plusieurs photos sur mon site(quand j'en met une ca fonctionne très bien)
mais plusieurs... si quelqu'un pourrais m'aider svp voici mon code
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
if($_FILES['photoun']['photodeux']['phototrois']['photoquatre']['error']==0)
{
//copie de la photo dans le répertoire /photos/
copy($_FILES['photoun']['photodeux']['phototrois']['photoquatre']['tmp_name'],"../photos/".$_FILES['photoun']['photodeux']['phototrois']['photoquatre']['name']);
//enregistrement des informations AVEC le nom de la photo
$updateSQL = sprintf("UPDATE categories SET categorie=%s, nom=%s, accroche=%s, 'description'=%s, prix=%s, photoun=%s, photodeux=%s, phototrois=%s, photoquatre=%s WHERE reference=%s",
GetSQLValueString($_POST['categorie'], "text"),
GetSQLValueString($_POST['nom'], "text"),
GetSQLValueString($_POST['accroche'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['prix'], "text"),
GetSQLValueString($_FILES['photoun']['name'], "text"),
GetSQLValueString($_FILES['photodeux']['name'], "text"),
GetSQLValueString($_FILES['phototrois']['name'], "text"),
GetSQLValueString($_FILES['photoquatre']['name'], "text"),
GetSQLValueString($_POST['reference'], "text"));
}else{
//enregistrement des informations SANS le nom de la photo
$updateSQL = sprintf("UPDATE categories SET categorie=%s, nom=%s, accroche=%s, 'description'=%s, prix=%s WHERE reference=%s",
GetSQLValueString($_POST['categorie'], "text"),
GetSQLValueString($_POST['nom'], "text"),
GetSQLValueString($_POST['accroche'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['prix'], "text"),
GetSQLValueString($_POST['reference'], "text"));
}
mysql_select_db($database_maConnexion, $maConnexion);
$Result1 = mysql_query($updateSQL, $maConnexion) or die(mysql_error());
$updateGoTo = "categoriesGestion.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_maConnexion, $maConnexion);
$query_rscategories = "SELECT * FROM categories";
$rscategories = mysql_query($query_rscategories, $maConnexion) or die(mysql_error());
$row_rscategories = mysql_fetch_assoc($rscategories);
$totalRows_rscategories = mysql_num_rows($rscategories);
?>
merci d'avance

1 réponse

  1. elpoueko
     
    petites précision ça c'est la partie modif, la partie ajout c'est :


    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    if($_FILES['photoun']['photodeux']['phototrois']['photoquatre']['error']==0)
    {
    //copie de la photo dans le répertoire /photos/
    copy($_FILES['photoun']['photodeux']['phototrois']['photoquatre']['tmp_name'],"../photos/".$_FILES['photoun']['photodeux']['phototrois']['photoquatre']['name']);
    //enregistrement des informations AVEC le nom de la photo
    $insertSQL = sprintf("INSERT INTO categories (reference, categorie, nom, accroche, 'description', prix, photoun, photodeux, phototrois, photoquatre) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['reference'], "text"),
    GetSQLValueString($_POST['categorie'], "text"),
    GetSQLValueString($_POST['nom'], "text"),
    GetSQLValueString($_POST['accroche'], "text"),
    GetSQLValueString($_POST['description'], "text"),
    GetSQLValueString($_POST['prix'], "text"),
    GetSQLValueString($_FILES['photoun']['name'], "text"),
    GetSQLValueString($_FILES['photodeux']['name'], "text"),
    GetSQLValueString($_FILES['phototrois']['name'], "text"),
    GetSQLValueString($_FILES['photoquatre']['name'], "text"));
    }else{
    //enregistrement des informations SANS le nom de la photo
    $insertSQL = sprintf("INSERT INTO categories (reference, categorie, nom, accroche, 'description', prix) VALUES (%s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['reference'], "text"),
    GetSQLValueString($_POST['categorie'], "text"),
    GetSQLValueString($_POST['nom'], "text"),
    GetSQLValueString($_POST['accroche'], "text"),
    GetSQLValueString($_POST['description'], "text"),
    GetSQLValueString($_POST['prix'], "text"));
    }

    mysql_select_db($database_maConnexion, $maConnexion);
    $Result1 = mysql_query($insertSQL, $maConnexion) or die(mysql_error());

    $insertGoTo = "categoriesGestion.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    mysql_select_db($database_maConnexion, $maConnexion);
    $query_rscategories = "SELECT * FROM categories";
    $rscategories = mysql_query($query_rscategories, $maConnexion) or die(mysql_error());
    $row_rscategories = mysql_fetch_assoc($rscategories);
    $totalRows_rscategories = mysql_num_rows($rscategories);
    ?>
    0