-----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 code:
...
$query = sprintf("select username from robots.acct where type='teacher'");
$result = mysql_query($query, $link);
$result = mysql_fetch_array($result);
foreach($result as $t_username)
{
echo "<option value='" . $t_username . "'>" . $t_username . "</option>";
}
...
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='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 direction?
- --
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
=RJxG
-----END PGP SIGNATURE-----
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Jun 3 13:17:09 2009
This archive was generated by hypermail 2.1.8 : Wed Jun 03 2009 - 13:17:09 AKDT