[aklug] Re: Noob php question

From: Josh Rhoades <kaiden11@gmail.com>
Date: Wed Jun 03 2009 - 13:25:18 AKDT

What's the HTML source returned by your PHP script?

On Wed, Jun 3, 2009 at 1:16 PM, Christopher Howard <choward@indicium.us> wr=
ote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi. Trying to write some PHP/MySQL at work, without really knowing what
> I'm doing. :] Hoped somebody could answer a small question. Here's my cod=
e:
>
> ...
> $query =3D sprintf("select username from robots.acct where type=3D'teache=
r'");
> $result =3D mysql_query($query, $link);
> $result =3D mysql_fetch_array($result);
> foreach($result as $t_username)
> =A0{
> =A0 =A0echo "<option value=3D'" . $t_username . "'>" . $t_username . "</o=
ption>";
> =A0}
> ...
>
> The output is inside a <select> tag in a form, so I want to create a
> selection box using values pulled from the MySQL database. When I run
> the same query in the MySQL client, I get this:
>
> mysql> select username from robots.acct where type=3D'teacher';
> +----------+
> | username |
> +----------+
> | teacher1 |
> | teacher2 |
> +----------+
> 2 rows in set (0.00 sec)
>
> However, the output spit out by the php only provides me with two
> values: "teacher1" and "teacher1".
>
> I'm guessing this is either because I'm not supposed to be using
> mysql_fetch_array(), or because I am not properly handling what
> mysql_fetch_array() returns. Could someone point me in the right directio=
n?
>
> - --
> Christopher Howard
> http://indicium.us
> http://theologia.indicium.us
>
> I digitally sign /all/ of my e-mails via PGP. If you receive any e-mail
> from me without my valid PGP signature, please take additional steps to
> verify the authenticity of the message.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkom6EIACgkQQ5FLNdi0BcWg1wCfcuBocjJAQIuCT3cuNfueUUZM
> A9sAoINZvkp28yU/rkYT7v1B/ZL3BqRj
> =3DRJxG
> -----END PGP SIGNATURE-----
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>
>
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Jun 3 13:25:29 2009

This archive was generated by hypermail 2.1.8 : Wed Jun 03 2009 - 13:25:29 AKDT