Ciao a tutti ho un piccolo problema con la modifica dei record.
Io voglio fare in modo che quando entro nel form per modificare il campo id non sia modificabile solo che quando modifico qlc mi da errore di sintassi...non riesce a prendermi l'id dell'appuntamento.
Se invece metto anche nel campo id l'input text mi funziona perfettamente.
Ecco il codice dove l'id non viene inserito in una textbox, quindi non modificabile.
Codice PHP:
<?php
$confirm=$_REQUEST['confirm'];
$id_appuntamento=$_REQUEST['id_appuntamento'];
if (!$confirm)
{
$dati=mysql_fetch_array(mysql_query("SELECT * FROM appuntamenti WHERE id_appuntamento=$id_appuntamento"));
//$sql="select * from appuntamenti where id_appuntamento=".$id_appuntamento;
//$result = mysql_query($sql, $db) or die (mysql_error());
$AffectedRows = mysql_affected_rows($db);
if ($AffectedRows==0)
{
echo "Non esistono record con i criteri selezionati";
}
else
{
?>
<h2>Modifica dati appuntamento</h2>
<table>
<form method="post" action="?indice=27">
<tr><td> Id </td>
<td><name="id_appuntamento"><?php echo $id_appuntamento; ?></td>
</tr>
<tr><td> Oggetto </td>
<td><input type="text" name="oggetto" size="40" value="<?php echo $dati['oggetto_appuntamento']; ?>" /></td>
</tr>
<tr><td> Data </td>
<td><input type="text" name="data" size="40" value="<?php echo $dati['data_appuntamento']; ?>" /></td>
</tr>
<tr><td> Lingua </td>
<td><input type="text" name="linguaappuntamenti" size="40" value="<?php echo $dati['id_lingua']; ?>" /></td>
</tr>
<tr><td> Testo </td>
<td>
<name="testo">
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = 'fckeditor/' ;
// Value diventa il testo estratto dal DATABASE
$oFCKeditor->Value = $dati['testo_appuntamento'];
$oFCKeditor->Width = "565px";
$oFCKeditor->Height = "350px";
$oFCKeditor->Create() ;
?>
</td>
</tr>
<tr><td> Data_reg </td>
<td><input type="text" name="data_registrazione" size="40" value="<?php echo $dati['data_registrazione_appuntamento']; ?>" /></td>
</tr>
<tr><td></td><td><input type="submit" value="Conferma modifiche"></td></tr>
<input type="hidden" name="confirm" value="1">
</form>
</table>
<?
//mysql_free_result($result);
mysql_close($db);
}
}
else
{
$data_registrazione = date("Y-m-d H:i:s");
$oggetto=$_REQUEST['oggetto'];
$data = $_REQUEST['data'];
$linguaappuntamenti=$_REQUEST['linguaappuntamenti'];
$testo = mysql_real_escape_string(trim($_REQUEST['FCKeditor1']));
$sql="update appuntamenti set oggetto_appuntamento='$oggetto', data_appuntamento='$data', id_lingua='$linguaappuntamenti', testo_appuntamento='$testo', data_registrazione_appuntamento='$data_registrazione' where id_appuntamento = $id_appuntamento";
var_dump($sql);
$result = mysql_query($sql, $db) or die("errore:".mysql_error());
$AffectedRows = mysql_affected_rows($db);
if ($AffectedRows!=0)
{
echo "Il record è stato aggiornato";
echo "<a href=\"?indice=24\">Torna alla lista</a>";
}
mysql_close($db);
}
?>
Qualcuno sa dirmi come fare per poter appunto aggiornare i dati senza che l'id si trovi dentro in una textbox?
Spero di essere stato chiaro.
Grazieeeee