updating - Mailing list pgsql-php

From angelo.rigo@globo.com
Subject updating
Date
Msg-id 3DC1AF0800029818@riosf06.globoi.com
Whole thread Raw
List pgsql-php
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.

<?php
$db = pg_connect("dbname=db user=user");
$query = "SELECT * FROM thetable";

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

printf ("<table border=1>
");

printf ("<tr
bgcolor='#66CCFF'><td><b>ID</b></td><td><b>Cidade</b></td><td><b>Estado</b></td><td><b>Local</b></td><td><b>Dia</b></td><td><b>Mês</b></td><td><b>Horário</b></td><td><b>Evento</b></td></tr>");
do
{
$myrow = pg_fetch_array ($result,$row);
printf ("<tr
bgcolor='$bgcolor'><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>
",$myrow[id],$myrow[cidade], $myrow[estado], $myrow[localidade],$myrow[dia],
$myrow[mes], $myrow[horario],$myrow[evento]);
$row++;
}
while ($row < $numrows);
printf ("</table><br>
");
pg_close($db);
?>

<form action="atual.php" method="post">
<TABLE>
<TR>    <TD>ID to modificar :</TD>
    <TD><input type="text" name="id" size="4" length="4" value="id"></TD>
</TR>
<TR>    <TD>Cidade : </TD>
    <TD><input type="text" name="cidade" size="80" length="80" value=""></TD>
</TR>
<TR>    <TD>Estado :</TD>
    <TD><input type="text" name="estado" size="80" length="80" value=""></TD>
</TR>
<TR>
    <TD>Local :</TD>
    <TD><input type="text" name="local" size="80" length="80" value=""></TD>
</TR>
<TR>
    <TD>Dia : </TD>
    <TD><input type="text" name="data" size="80" length="80" value=""></TD>
</TR>
<TR>
    <TD>Mês :</TD>
    <TD><input type="text" name="data" size="80" length="80" value=""></TD>
</TR>
<TR>
    <TD>Horário :</TD>
    <TD><input type="text" name="horario" size="80" length="80" value=""></TD>
</TR>
<TR>
    <TD>Evento :</TD>
    <TD><input type="text" name="evento" size="80" length="80" value=""></TD>
</TR>
<TR>
    <TD><input type="submit" name="submit" value="Atualizar"></TD>
    <TD><input type="reset" name="reset" value="Limpar"></TD>
</TR>
</TABLE>



// atual .php

<?php
$db = pg_connect("dbname=db user=puser");
$query = "UPDATE thetable SET $id='$id', cidade='$cidade', estado='$estado',
localidade='$localidade', dia='$dia', mes='$mes', horario='$horario', evento='$evento'
WHERE id='$id'";
$result = 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.



pgsql-php by date:

Previous
From: Andrew McMillan
Date:
Subject: Re: Column names
Next
From: "YC Nyon"
Date:
Subject: Re: Spaawn another process