|
Posted by finbogey jones on 12/05/06 22:33
OK, total noob here trying to teach himself PHP/mySQL by reading books
and playing with code from the web and from trying to write increasingly
difficult (for me) code. Here's what I'm trying to do:
I have a db with a few tables. I have managed to write a simple query to
one of these tables that then displays all the fields of each record
that matches the query. Now I want to take it one step further, I want
to create a drop down selection box where the user can select any of
these records. I managed to create the box, but can only display one
field of the records (so if the fields were firstname and lastname, I
have only figured out how to show one of the two in the dropdown).
Any hints would be appreciated,or pointers to good web resources for
examples.
Here's the query code. I have deleted the form part as it is crap and
I'd like to see how it is properly done.
-----------------------------
$query = "SELECT ID, first, last FROM master WHERE fhl is null";
$result = mysql_query($query) or die('Error, query failed');
$tsv = array();
$html = array();
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$tsv[] = implode("\t", $row);
$html[] = "<tr><td>" .implode("</td><td>", $row) .
"</td></tr>";
}
$tsv = implode("\r\n", $tsv);
$html = "<table>" . implode("\r\n", $html) . "</table>";
[Back to original message]
|