Re: Using two colomns of mysql data as key/value pairs in arrays
| From: | David T-G | Date: | Mon, 20 Oct 2003 15:06:57 +0000 |
| Subject: | Re: Using two colomns of mysql data as key/value pairs in arrays | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-31179@lists.php.net to get a copy of this message | ||
Devon --
..and then Devon said...
%
% David T-G wrote:
%
% >Note that I don't recommend this as the best approach, and I don't think
..
% >doing it in two steps of loading your $everyone and then spitting out I'd
% >probably do something like
% >
% > $sql = "select id,name from a_table order by department" ;
% > $result = mysql_query($sql) ;
% > while ( $row = mysql_fetch_array($result) )
% > { print "ID: {$row['id']}\tName: {$row['name']}<br>\n"
; }
% >
% >to just run through the data. I'm sure others here know of even better
% >ways to print a roster :-)
..
%
% Indeed, I was trying to simply display a list of the data. I had coded
% the formatting and displaying first, based on the array I described,
% then tackled the MySQL part last. I see now that it prevented me from
Been there; oops-ed that. You can even let the DB format your output for
you so that it spits out HTML and then you're *really* on your way to
just dumping the output to the page! :-)
% seeing the better idea of removing the array from the equation
% completely. Your information was invaluble.
Happy to help!
%
% I did however go with mysql_fetch_assoc instead of mysql_fetch_array for
% efficiency. :)
I hear more and more that that's the way to go :-)
HAND
:-D
--
David T-G * There is too much animal courage in
(play) davidtg@justpickone.org * society and not sufficient moral courage.
(work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur
Pbzzhavpngvbaf Qrprapl Npg!