Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 14 su 14
  1. #11
    Utente di HTML.it
    Registrato dal
    Jan 2002
    Messaggi
    332
    quindi devo creare una nuova pagina per modificare il record?

  2. #12
    non neccesariamente. probailmente si può fare anche nella stessa pagina però con un valore sentinalla all'inizio del codice che, se TRUE esegue header, se no, va avanti.

    se posti un pò piu di codice forse riesco a darti una mano

  3. #13
    Utente di HTML.it
    Registrato dal
    Jan 2002
    Messaggi
    332
    ecco il codice che si trova nella pagina di aggiornamento:
    <?php require_once('../Connections/autovetture.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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")) {
    $updateSQL = sprintf("UPDATE modelli SET info=%s, marca=%s, modello=%s, cc=%s, alimentazione=%s, anno=%s, km=%s, colore=%s, prezzo=%s, tipologia=%s, riferimento=%s, interni=%s, immatricolazione=%s, posti=%s, porte=%s, accessori=%s, cambio=%s, classe=%s, trazione=%s WHERE ID=%s",

    GetSQLValueString($_POST['marca'], "text"),
    GetSQLValueString($_POST['modello'], "text"),
    GetSQLValueString($_POST['cc'], "int"),
    GetSQLValueString($_POST['alimentazione'], "text"),
    GetSQLValueString($_POST['anno'], "int"),
    GetSQLValueString($_POST['km'], "int"),
    GetSQLValueString($_POST['colore'], "text"),
    GetSQLValueString($_POST['prezzo'], "double"),
    GetSQLValueString($_POST['tipologia'], "text"),
    GetSQLValueString($_POST['riferimento'], "int"),
    GetSQLValueString($_POST['interni'], "text"),
    GetSQLValueString($_POST['immatricolazione'], "int"),
    GetSQLValueString($_POST['posti'], "int"),
    GetSQLValueString($_POST['porte'], "int"),
    GetSQLValueString($_POST['accessori'], "text"),
    GetSQLValueString($_POST['cambio'], "text"),
    GetSQLValueString($_POST['classe'], "text"),
    GetSQLValueString($_POST['trazione'], "text"),
    GetSQLValueString($_POST['ID'], "int"));

    mysql_select_db($database_autovetture, $autovetture);
    $Result1 = mysql_query($updateSQL, $autovetture) or die(mysql_error());

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

    $maxRows_Recordset1 = 10;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
    $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    }
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

    $colname_Recordset1 = "-1";
    if (isset($_GET['recordID'])) {
    $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
    }
    mysql_select_db($database_autovetture, $autovetture);
    $query_Recordset1 = sprintf("SELECT * FROM modelli WHERE ID = %s", $colname_Recordset1);
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $autovetture) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);

    if (isset($_GET['totalRows_Recordset1'])) {
    $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
    $all_Recordset1 = mysql_query($query_Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    }
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

    $colname_Recordset2 = "-1";
    if (isset($_GET['ID'])) {
    $colname_Recordset2 = (get_magic_quotes_gpc()) ? $_GET['ID'] : addslashes($_GET['ID']);
    }
    mysql_select_db($database_autovetture, $autovetture);
    $query_Recordset2 = sprintf("SELECT * FROM modelli WHERE ID = %s", $colname_Recordset2);
    $Recordset2 = mysql_query($query_Recordset2, $autovetture) or die(mysql_error());
    $row_Recordset2 = mysql_fetch_assoc($Recordset2);
    $totalRows_Recordset2 = mysql_num_rows($Recordset2);
    ?>
    <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
    <table align="center">
    <tr valign="baseline">
    <td nowrap align="right">ID:</td>
    <td><?php echo $row_Recordset1['ID']; ?></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Marca:</td>
    <td><input type="text" name="marca" value="<?php echo $row_Recordset1['marca']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Modello:</td>
    <td><input type="text" name="modello" value="<?php echo $row_Recordset1['modello']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Cc:</td>
    <td><input type="text" name="cc" value="<?php echo htmlentities($row_Recordset1['cc']); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Alimentazione:</td>
    <td><input type="text" name="alimentazione" value="<?php echo $row_Recordset1['alimentazione']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Anno:</td>
    <td><input type="text" name="anno" value="<?php echo $row_Recordset1['anno']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Km:</td>
    <td><input type="text" name="km" value="<?php echo $row_Recordset1['km']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Colore:</td>
    <td><input type="text" name="colore" value="<?php echo $row_Recordset1['colore']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Prezzo:</td>
    <td><input type="text" name="prezzo" value="<?php echo $row_Recordset1['prezzo']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Tipologia:</td>
    <td><input type="text" name="tipologia" value="<?php echo $row_Recordset1['tipologia']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Riferimento:</td>
    <td><input type="text" name="riferimento" value="<?php echo $row_Recordset1['riferimento']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Interni:</td>
    <td><input type="text" name="interni" value="<?php echo $row_Recordset1['interni']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Immatricolazione:</td>
    <td><input type="text" name="immatricolazione" value="<?php echo $row_Recordset1['immatricolazione']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Posti:</td>
    <td><input type="text" name="posti" value="<?php echo $row_Recordset1['posti']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Porte:</td>
    <td><input type="text" name="porte" value="<?php echo $row_Recordset1['porte']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Accessori:</td>
    <td><input type="text" name="accessori" value="<?php echo $row_Recordset1['accessori']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Cambio:</td>
    <td><input type="text" name="cambio" value="<?php echo $row_Recordset1['cambio']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Classe:</td>
    <td><input type="text" name="classe" value="<?php echo $row_Recordset1['classe']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Trazione:</td>
    <td><input type="text" name="trazione" value="<?php echo $row_Recordset1['trazione']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right"></td>
    <td><input name="submit" type="submit" value="vai alla pagina Aggiorna record" /></td>
    </tr>
    </table>
    <?php echo $row_Recordset1['info']; ?>
    <input type="hidden" name="hiddenField" />
    <input type="hidden" name="MM_update" value="form1">
    <input type="hidden" name="ID" value="<?php echo $row_Recordset1['ID']; ?>">
    </form>


    </p>


    </p>
    <?php
    mysql_free_result($Recordset1);

    mysql_free_result($Recordset2);
    ?>

  4. #14
    Utente di HTML.it
    Registrato dal
    Jan 2002
    Messaggi
    332
    ho risolto. grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.