updating

updating

am 06.11.2002 17:23:12 von angelo.rigo

Hi

I am working on an update php script, i have a list of the records and at
the bottom of the script i do write the id number
on the id field i want to change and the others fields values, i have to
write it, i want to select with a radio button and to get the fields at
the bottom receiving the values of that line i do select how can i do that?


Below is my script:
//part one: list and update form.

$db =3D pg_connect("dbname=3Ddb user=3Duser");
$query =3D "SELECT * FROM thetable";

$result =3D pg_exec($db, $query);
if (!$result) {printf ("ERROR"); exit;}
$numrows =3D pg_numrows($result);
$row=3D0;

printf ("


");

printf (" d>Estado");
do
{
$myrow =3D pg_fetch_array ($result,$row);
printf ("
",$myrow[id],$myrow[cidade], $myrow[estado], $myrow[localidade],$myrow[dia],
$myrow[mes], $myrow[horario],$myrow[evento]);
$row++;
}
while ($row < $numrows);
printf ("
IDCidadeLocalDiaM=EAs >Hor=E1rioEvento
%s%s%s%s td>%s%s%s%s


");
pg_close($db);
?>




































ID to modificar : =
Cidade : =3D"">
Estado : =3D"">
Local : "">
Dia : ">
M=EAs : ">
Hor=E1rio : =3D"">
Evento : =3D"">




// atual .php

$db =3D pg_connect("dbname=3Ddb user=3Dpuser");
$query =3D "UPDATE thetable SET $id=3D'$id', cidade=3D'$cidade', estado=3D'=
$estado',
localidade=3D'$localidade', dia=3D'$dia', mes=3D'$mes', horario=3D'$horario=
', evento=3D'$evento'
WHERE id=3D'$id'";
$result =3D pg_exec($db, $query);
if (!$result) {printf ("ERROR"); exit;}
printf ("these values were updated: %s %s %s %s %s %s %s %s", $id, $cidade,
$estado, $localidade, $dia, $mes, $horario, $evento);
pg_close($db);
?>


________________________________________
A busca mais veloz e precisa da internet. Acesse agora: http://www.zoom.com=
..br.



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html