pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedmake form list with option select
4+ messages / 3 participants
[nested] [flat]
* make form list with option select
@ 2003-03-26 05:05 Ahmad Sentri <sentri@unila.ac.id>
2003-03-26 06:53 ` Re: make form list with option select apz <apz@nofate.com>
0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Sentri @ 2003-03-26 05:05 UTC (permalink / raw)
To: pgsql-php
hi ..
this my problem with php-postgresql
this syntax php with postgresql ....
this syntax still wrong / error
in my form doesn't list ...
<th width="20%" align="left" nowrap>Kode Fakultas</th>
<td width="72%"><select name="kode_fak">select kode_fak<option>
<?php
$query1="select kode_fak, nama_fak from fakultas";
$query_result1 = pg_query($conn, $query1);
while ($row1 = pg_fetch_array($query_result1))
{
echo "<option
value=\"$row1[kode_fak]"\>$row1[nama_fak]</option>\n";
}
?>
</select>
</td>
table in postgresql
CREATE TABLE FAKULTAS (KODE_FAK CHAR (1)NOT NULL,
NAMA_FAK VARCHAR (50),
NAMA_FAK_EN VARCHAR (50),
CONSTRAINT XPKFAKULTAS
PRIMARY KEY (KODE_FAK));
help me please ...
thank's
newbie php-postgresql
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: make form list with option select
2003-03-26 05:05 make form list with option select Ahmad Sentri <sentri@unila.ac.id>
@ 2003-03-26 06:53 ` apz <apz@nofate.com>
2003-03-26 06:59 ` Re: make form list with option select apz <apz@nofate.com>
0 siblings, 1 reply; 4+ messages in thread
From: apz @ 2003-03-26 06:53 UTC (permalink / raw)
To: Ahmad Sentri <sentri@unila.ac.id>; +Cc: pgsql-php
Ahmad Sentri wrote:
> this syntax php with postgresql ....
> this syntax still wrong / error
> in my form doesn't list ...
I am assuming that $conn is created somewhere above ok
> <?php
> $query1="select kode_fak, nama_fak from fakultas";
> $query_result1 = pg_query($conn, $query1);
> while ($row1 = pg_fetch_array($query_result1))
> {
> echo "<option
> value=\"$row1[kode_fak]"\>$row1[nama_fak]</option>\n";
> }
>
> ?>
first thing I would think of is how you access $row1
1. prolly you meant $row1["kode_fak"]
you should quote your keyname, otherwise php thinks its something
special, not a variable, not a string
2. I think its more obvious for compiler if you do it more explicitly:
echo "<option value='".$row1["kode_fak"].".>".$row1["mana_fak"].
"</option>\n";
3. there is pg_fetch_assoc, but since am newbie myself I am not sure
wether its better to use pg_fetch_array and hope for it to be
associative, or better use pg_fetch_assoc and be more guaranteed
about it. anyone bother to comment? is pg_fetch_assoc an old timer
function and pg_fetch_array is the main to use?
hope this helps, enjoy
/apz, Condense soup, not books!
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: make form list with option select
2003-03-26 05:05 make form list with option select Ahmad Sentri <sentri@unila.ac.id>
2003-03-26 06:53 ` Re: make form list with option select apz <apz@nofate.com>
@ 2003-03-26 06:59 ` apz <apz@nofate.com>
2003-03-26 16:11 ` Re: make form list with option select Ray Hunter <rhunter@venticon.com>
0 siblings, 1 reply; 4+ messages in thread
From: apz @ 2003-03-26 06:59 UTC (permalink / raw)
To: ; +Cc: Ahmad Sentri <sentri@unila.ac.id>; pgsql-php
apz screwed up:
> echo "<option value='".$row1["kode_fak"].".>".$row1["mana_fak"].
> "</option>\n";
it should say:
echo "<option value='".$row1["kode_fak"]."'>".$row1["mana_fak"].
"</option>\n";
if you dont see it, I had ".>" while should be "'>" (to close the html
value string for the option tag). blah, hope this does not deter from
getting this thing for you to work.
enjoy
/apz, Learn to pause -- or nothing worthwhile can catch up to you.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: make form list with option select
2003-03-26 05:05 make form list with option select Ahmad Sentri <sentri@unila.ac.id>
2003-03-26 06:53 ` Re: make form list with option select apz <apz@nofate.com>
2003-03-26 06:59 ` Re: make form list with option select apz <apz@nofate.com>
@ 2003-03-26 16:11 ` Ray Hunter <rhunter@venticon.com>
0 siblings, 0 replies; 4+ messages in thread
From: Ray Hunter @ 2003-03-26 16:11 UTC (permalink / raw)
To: apz <apz@nofate.com>; +Cc: Ahmad Sentri <sentri@unila.ac.id>; pgsql-php
Or you could just do this to:
echo
"<option value=\"{$row1['kode_fak']}\">{$row1['mana_fak']}</option>\n";
That will work too...
--
Ray
On Tue, 2003-03-25 at 23:59, apz wrote:
> apz screwed up:
> > echo "<option value='".$row1["kode_fak"].".>".$row1["mana_fak"].
> > "</option>\n";
>
> it should say:
>
> echo "<option value='".$row1["kode_fak"]."'>".$row1["mana_fak"].
> "</option>\n";
>
>
> if you dont see it, I had ".>" while should be "'>" (to close the html
> value string for the option tag). blah, hope this does not deter from
> getting this thing for you to work.
>
>
> enjoy
>
>
>
> /apz, Learn to pause -- or nothing worthwhile can catch up to you.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-03-26 16:11 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-26 05:05 make form list with option select Ahmad Sentri <sentri@unila.ac.id>
2003-03-26 06:53 ` apz <apz@nofate.com>
2003-03-26 06:59 ` apz <apz@nofate.com>
2003-03-26 16:11 ` Ray Hunter <rhunter@venticon.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox