From: apz <apz@nofate.com>
To: Ahmad Sentri <sentri@unila.ac.id>
Cc: pgsql-php@postgresql.org
Subject: Re: make form list with option select
Date: Wed, 26 Mar 2003 01:53:55 -0500
Message-ID: <3E814E83.9070108@nofate.com> (raw)
In-Reply-To: <Pine.BSF.4.21.0303261200580.41767-100000@maiser.unila.ac.id>
References: <Pine.BSF.4.21.0303261200580.41767-100000@maiser.unila.ac.id>
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!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: apz@nofate.com, sentri@unila.ac.id
Subject: Re: make form list with option select
In-Reply-To: <3E814E83.9070108@nofate.com>
References: <Pine.BSF.4.21.0303261200580.41767-100000@maiser.unila.ac.id> <3E814E83.9070108@nofate.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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