forms /selects

From: angelo(dot)rigo(at)globo(dot)com
To: pgsql-php(at)postgresql(dot)org
Subject: forms /selects
Date: 2002-12-10 12:29:38
Message-ID: 3DCBFE22000E6871@riosf06.globoi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hi all

I am trying to do a select from a table after the user has choosen the first
letter of the name and it must display only the names with that letter selected
in a select box. The message i get is if i select a for example is:
"the atribute 'a' not found"

I would like some help to know what?s going wrong!
Thank?s in advance

Ângelo Rigo

Here is my code:

Search names by the first letter
<BR><form method="post" size="1" action="<?php print("$PHP_SELF"); ?>">
<select size="1" name="leter">
<option selected>Choose an initial leter
<option value=A>A
<option value=B>B
<option value=C>C
<option value=D>D
<option value=E>E
<option value=F>F
<option value=G>G
<option value=H>H
<option value=I>I
<option value=J>J
<option value=K>K
<option value=L>L
<option value=M>M
<option value=N>N
<option value=O>O
<option value=P>P
<option value=Q>Q
<option value=R>R
<option value=S>S
<option value=T>T
<option value=U>U
<option value=V>V
<option value=X>X
<option value=Y>Y
<option value=Z>Z
</select><input type="submit" value="Submit"></form></TD>
</TR>
</TABLE> <br>
<?php
$db = pg_connect("dbname=db user=user");
$query ="SELECT name FROM thetable WHERE (nome=$leter%) ORDER BY nome ASC
";
$result = pg_exec($db, $query);

if (!$result) {printf ("Error!"); exit;}
$numrows = pg_numrows($result);
$row=0;
printf ("<table border=0>");
printf ("<tr bgcolor='#FFFF33'><td><b>Name</b></td></tr>");
do
{
$myrow = pg_fetch_array ($result,$row);
if($row % 2) {
$bgcolor="#FFFF99";
}
else {
$bgcolor="";
}
printf ("<tr bgcolor='$bgcolor'><td>%s</td></tr>",$myrow[nome]);
$row++;
}
while ($row < $numrows);
printf ("</table>");
pg_close($db);
?>

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

Browse pgsql-php by date

  From Date Subject
Next Message jco 2002-12-10 13:56:40 Re: Large file upload
Previous Message Vince Vielhaber 2002-12-10 11:40:31 Re: Large file upload