- Home
- Categorie
- Coding e Sistemistica
- PHP
- update che non aggiorna
-
fai un echo di $id e vedi se ha il valore giusto oppure per strada si eprde qualcosa...
-
@Thedarkita said:
fai un echo di $id e vedi se ha il valore giusto oppure per strada si eprde qualcosa...
hai ragione perdo l'id
infatti mi stampa 0
cosa dovrei fare, il passaggio per il recupero dell'id sembra giustociao
penso di si
nella pagina del form modifica ho questa text dove mi scrive id
<?php
print"
<input type='text' name='id' value='" .$_GET['id']. "'>";
?>
quindi quando clicco su modifica e mi appare il form modifica l'id è presente,
quando clicco su salva modifiche mi da come id 0
-
$_GET['id']
sicuro sia preso in get come id, o sbagli nome?
-
@Thedarkita said:
$_GET['id']
sicuro sia preso in get come id, o sbagli nome?
penso di si
nella pagina del form modifica ho questa text dove mi scrive id
[PHP]<?php
print"
<input type='text' name='id' value='" .$_GET['id']. "'>";
?>
[/PHP]
quindi quando clicco su modifica e mi appare il form modifica l'id è presente,
quando clicco su salva modifiche mi da come id 0
-
il form è col metodo get?
perchè l'unico motivo per andare a 0 è che non passi la variabile...
-
si ho appena fatto dei cambiamenti,ho messo a tutti GET
ma il problema mi resta
dimmi cosa dovrei postarti
-
posta la pagina con il form completa...
-
[php]
<?php
require_once 'Config.php';
require_once 'Connect.php';
if(!isset($_SESSION['username']))
{
$messaggio=urlencode("Ti consiglio di autenticarti");
header('location:'.'watch/accept.php'.'?msg='.$messaggio);
exit;
}//Creo la select per la visualizzazione delle categorie
$query="SELECT * FROM categorie ORDER BY descrizione";
//eseguo la query
$risultato_categoria=mysql_query($query);//creo la SELECT
$query_2="SELECT * FROM articoli WHERE id_articolo='".$_GET['id']."'";
//eseguo la query
$risultato_2=mysql_query($query_2);
if(!$risultato_2)
{
die("errore nella query;".mysql_error());
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="it">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Inserimento nuovo articolo</title>
<link href="temp9.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.Stile1 {font-family: Arial, Helvetica, sans-serif}
.Stile3 {font-family: Arial, Helvetica, sans-serif; color: #990000; }
-->
</style>
</head>
<body>
<div align="left">
<form method="GET" action="Articolo/update_articolo.php">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="731" height="400">
<tr>
<td width="367" height="21">
<p align="left"><b>
<font size="2" face="Bookman Old Style" color="#0000FF"> Modifica
articolo</font></b></td>
<td width="358" height="420" rowspan="2" valign="top">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="363">
<tr>
<td width="100%" height="20" valign="top" colspan="2"> </td>
</tr>
<tr>
<td width="100%" height="21" valign="top" colspan="2"> </td>
<?php
$riga2=mysql_fetch_array($risultato_2,MYSQL_ASSOC);
?>
</tr>
<tr>
<td width="33%" height="21" valign="top">
<font face="Bookman Old Style" size="2">Immagine 1</font></td>
<td width="67%" height="21" valign="top">
<font face="Bookman Old Style" size="2">
<?php
print"
<input type='text' name='frm_codice' class='inputText12' size='20' value='$riga2[img_1]'>";
?>
</font></td>
</tr>
<tr>
<td width="33%" height="22" valign="top">
<font face="Bookman Old Style" size="2">Immagine 2</font></td>
<td width="67%" height="22" valign="top">
<font face="Bookman Old Style" size="2">
<?php
print"
<input type='text' name='frm_codice' class='inputText12' size='20' value='$riga2[img_2]'>";
?>
</font></td>
</tr>
<tr>
<td width="33%" height="24" valign="top">
<font face="Bookman Old Style" size="2">Immagine 3</font></td>
<td width="67%" height="24" valign="top">
<font face="Bookman Old Style" size="2">
<?php
print"
<input type='text' name='frm_codice' class='inputText12' size='20' value='$riga2[img_3]'>";
?>
</font></td>
</tr>
<tr>
<td width="33%" height="21" valign="top">
<font face="Bookman Old Style" size="2">Immagine 4</font></td>
<td width="67%" height="21" valign="top">
<font face="Bookman Old Style" size="2">
<?php
print"
<input type='text' name='frm_codice' class='inputText12' size='20' value='$riga2[img_4]'>";
?>
</font></td>
</tr>
<tr>
<td width="100%" height="19" valign="top" colspan="2">
<font face="Bookman Old Style" size="2">Caratteristica</font></td>
</tr>
<tr>
<?php
print"<td width='100%' height='168' valign='top' colspan='2'>
<textarea name='frm_caratteristica' rows='7' cols='4' class='inputTextArea'>$riga2[caratteristica]</textarea></td>";
?>
</tr>
<tr>
<td width="100%" height="44" colspan="2" align="left">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="27">
<tr>
<td width="72%" height="27"> </td>
<td width="23%" height="27" align="right">
<input name="image" type="image" value="Salva" src="immages/q9.gif" border="0" img></td>
<td width="5%" height="27"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="367" height="395" valign="top">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="300">
<tr>
<td width="100%" height="19" valign="top" colspan="2"> </td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font size="2" face="Bookman Old Style"> Codice articolo</font></td>
<td width="64%" height="19" valign="top">
<font face="Bookman Old Style" size="2">
<?php
print"
<input type='text' name='frm_codice' class='inputText' size='20' value='$riga2[codice]'>";
?>
</font></td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font face="Bookman Old Style" size="2"> Descrizione</font></td>
<td width="64%" height="19" valign="top">
<font face="Bookman Old Style" size="2">
<?php
print"
<input type='text' name='frm_descrizione' class='inputText' size='20' value='$riga2[descrizione]'>";
?>
</font></td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font face="Bookman Old Style" size="2"> Categoria</font></td>
<td width="64%" height="19" valign="top">
<?php
print"
<select size='1' name='frm_categoria' class='inputList'>";
while($riga=mysql_fetch_array($risultato_categoria,MYSQL_ASSOC))
{
if($riga[id_categ]==$riga2[id_categ])
{
echo'<option selected value="'.intval($riga[id_categ]).'">'.$riga[Descrizione].'</option>';
}
else
{
echo'<option value="'.intval($riga[id_categ]).'">'.$riga[Descrizione].'</option>';
}
}
print"
</select>";
?>
</td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font face="Bookman Old Style" size="2"> Prezzo</font></td>
<td width="64%" height="19" valign="top">
<font face="Bookman Old Style" size="2">
<?php
print"
<input type='text' name='frm_prezzo' class='inputText' size='20' value='$riga2[prezzo]'>";
?>
</font></td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font face="Bookman Old Style" size="2"> Disponibile</font></td>
<td width="64%" height="19" valign="top">
<font size="2" face="Bookman Old Style">Si/No</font>
<?php
if($riga2['disponibile']=="Si")
{
print"<input type='checkbox' name='frm_disponibile' checked>";
}
else
{
print"<input type='checkbox' name='frm_disponibile'>";
}
?>
</td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font face="Bookman Old Style" size="2"> Offerta</font></td>
<td width="64%" height="19" valign="top">
<font size="2" face="Bookman Old Style">Si/No</font>
<?php
if($riga2['offerta']=="1")
{
print"<input type='checkbox' name='frm_offerta' checked>";
}
else
{
print"<input type='checkbox' name='frm_offerta'>";
}
?>
</td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font face="Bookman Old Style" size="2"> Novità</font></td>
<td width="64%" height="19" valign="top">
<font size="2" face="Bookman Old Style">Si/No</font>
<?php
if($riga2['novita']=="1")
{
print"<input type='checkbox' name='frm_novita' checked>";
}
else
{
print"<input type='checkbox' name='frm_novita'>";
}
?>
</td>
</tr>
<tr>
<td width="36%" height="19" valign="bottom">
<font face="Bookman Old Style" size="2"> Richiesto</font></td>
<td width="64%" height="19" valign="top">
<font size="2" face="Bookman Old Style">Si/No</font>
<?php
if($riga2['richiesto']=="1")
{
print"<input type='checkbox' name='frm_richiesto' checked>";
}
else
{
print"<input type='checkbox' name='frm_richiesto'>";
}
?>
</td>
</tr>
<tr>
<td width="100%" height="118" valign="bottom" colspan="2">
<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse">
<tr>
<?php
if(isset($_GET['msg']))
{
echo "<td width='260' height='12' valign='top' align='left'>
<font face='Palatino Linotype' size='2' color='#3333FF'>" . stripslashes($_GET['msg']) . "</font></td>";
}
?>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<?php
print"
<input type='text' name='id' value='" .$_GET['id']. "'>";
?>
</body>
</html>
[/php]non guardare dove carico il nome delle immagini ci sto appena lavorando come noterai gli input si chiamano tutti frm_codice
-
l'input è fuori dal form... non passa niente in quel modo
-
@Thedarkita said:
l'input è fuori dal form... non passa niente in quel modo
forse non ci crederai ma il pensiero c'era di spostarlo, ma visto che mi passava l'id quando richiamavo la pagina non gli ho dato peso
che fessacchiottocmq ho provato tutto ok
grazie
-
prego