From: "Chris Boget" <[EMAIL PROTECTED]>
> > From: "Chris Boget" <[EMAIL PROTECTED]>
> > > My bad.
> > > If MySQL had crosstab functionality, that *might* be able to help.
> > A "crosstab" is just a specifically formatted query, of which MySQL is
> > certainly capable of handling. I've done them in
From: "David T-G" <[EMAIL PROTECTED]>
> [Actually, maybe I'm just too new at this, but I
> can't think of a practical example for which I would loop over $row...
> Care to help me out?]
How about a dynamic query where you do not know the number of columns
that'll be returned? You would not want t
> From: "Chris Boget" <[EMAIL PROTECTED]>
> > My bad.
> > If MySQL had crosstab functionality, that *might* be able to help.
> A "crosstab" is just a specifically formatted query, of which MySQL is
> certainly capable of handling. I've done them in the past, but maybe you're
> thinking of something
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Jon, et al --
...and then Jon Kriek said...
%
% Perhaps if you would stop sending your posts at attachments ;)
Oh, that. I blame your mail mangler still, but this message has been
folded, spindled, and mutilated just for you :-)
HAND
:-D
- --
D
Chris, et al --
...and then Chris Boget said...
%
...
% > than maybe making my script run a little more slowly, I fail to see how
% > mysql_fetch_array() is a bad thing. From what I can see, all it does is give
% > me an additional numerically indexed reference to the data in my result set
...
%
From: "Chris Boget" <[EMAIL PROTECTED]>
> My bad.
> If MySQL had crosstab functionality, that *might* be able to help.
A "crosstab" is just a specifically formatted query, of which MySQL is
certainly capable of handling. I've done them in the past, but maybe you're
thinking of something more compl
Perhaps if you would stop sending your posts at attachments ;)
>> Dude, your quoting *really* needs some help
--
Jon Kriek
http://phpfreaks.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
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
Chris, et al --
...and then Chris Boget said...
%
% > % Actually, mysql_fetch_assoc() will do quite nicely.
% > Really? How? I must be quite confused.
%
% No, actually, I am the one who's confused. I misread the OP's email such
% that *_assoc() would do the job.
*whew* Glad to hear that --
Jon, et al --
...and then Jon Kriek said...
%
% Trust me, I was not "shooting anyone down", I would rather quit programming
% then do that - seriously.
Fair enough, and truce declared. Now to simply discuss the finer points
of mysql_fetch_* :-)
%
% --
% Jon Kriek
% http://phpfreaks.com
HA
David T-G wrote:
Note that I don't recommend this as the best approach, and I don't think
that anyone else does, either. Usually you want to avoid sucking an
entire database into your script's memory; the database (and its coders)
almost always handles data better than we mere mortals. A much be
Jon --
...and then Jon Kriek said...
%
% Easier is not always "right" or "good script-logic"
Admitted. I just want to know why it's wrong or so-very-not-good.
%
% Would it be easier for you to type:
%
% mysql_fetch_array($result, MYSQL_ASSOC) {
If I needed to care about the space used by a
Cpt John W. Holmes wrote:
while($r = mysql_fetch_assoc($result))
{ $array[$r['id']] = $r['name']; }
---John Holmes...
Wonderful! Thats exactly what I was looking for! I ended up taking the
array out of the equation entirly as suggested by Davic T-G, but the
simplicity of your answer was exactly
30% increase is more than I was expecting, but nonetheless I was correct.
--
Jon Kriek
http://phpfreaks.com
"Peter Beckman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Mysql_fetch_assoc() is faster -- use it.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscri
> result set. Chris, you've made a believer out of me; I'll start using
> mysql_fetch_assoc() for these kinds of queries from now on.
:p
> And in the spirit of only retrieving what you need from the database, I
> would agree that mysql_fetch_assoc() is the "better" option. However, other
> than
OTECTED]>
Sent: Monday, October 20, 2003 4:13 PM
Subject: Re: [PHP-DB] Using two colomns of mysql data as key/value pairs in
arrays
> That is your personal opinion to which you are entitled to, but again
> "shooting someone down" is just not the case in this situation.
>
>
On Mon, 20 Oct 2003, Jon Kriek wrote:
> Easier is not always "right" or "good script-logic"
>
> Would it be easier for you to type:
>
> mysql_fetch_array($result, MYSQL_ASSOC) {
OK, can we clear this up once and for all?
mysql_fetch_assoc(): 3.7182140350342 seconds [18880 rows]
mysql_fetch_
That is your personal opinion to which you are entitled to, but again
"shooting someone down" is just not the case in this situation.
>> No, but IMNSHO he shot a rather rude hole in Ignatius.
"David T-G" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
--
PHP Database Mailing List (
> % > The original poster actually mentioned an associative array with one
> % > field as the index and another as the value. None of these, just
> % > Ignatius's suggestion, will do the job.
> % Actually, mysql_fetch_assoc() will do quite nicely.
> Really? How? I must be quite confused.
No,
Trust me, I was not "shooting anyone down", I would rather quit programming
then do that - seriously.
--
Jon Kriek
http://phpfreaks.com
"David T-G" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.
Chris --
...and then Chris Boget said...
%
% > The original poster actually mentioned an associative array with one db
% > field as the index and another as the value. None of these, just like
% > Ignatius's suggestion, will do the job.
%
% Actually, mysql_fetch_assoc() will do quite nicely.
Chris Boget wrote:
The original poster actually mentioned an associative array with one db
field as the index and another as the value. None of these, just like
Ignatius's suggestion, will do the job.
Actually, mysql_fetch_assoc() will do quite nicely.
Im afraid not. I already tried that. It u
Easier is not always "right" or "good script-logic"
Would it be easier for you to type:
mysql_fetch_array($result, MYSQL_ASSOC) {
>> It's easier for me to just always use mysql_fetch_array instead of
figuring out whether I want mysql_fetch_row, mysql_fetch_assoc, or both.
"David T-G" <[EMAIL PRO
Chris, et al --
...and then Chris Boget said...
%
% Actually, for an associative array (which the OP had made reference
% to), you use mysql_fetch_assoc().
See my response to Jon. No single function of which I know is going to
pull what he requested out of the database in the format he desires.
> The original poster actually mentioned an associative array with one db
> field as the index and another as the value. None of these, just like
> Ignatius's suggestion, will do the job.
Actually, mysql_fetch_assoc() will do quite nicely.
> I didn't think it worth shooting down someone who wa
gt; > Sent: Monday, October 20, 2003 9:42 AM
> > To: Ignatius Reilly; [EMAIL PROTECTED]; Devon
> > Subject: Re: [PHP-DB] Using two colomns of mysql data as
> > key/value pairs
> > in arrays
> >
> >
> > > mysql_fetch_array( $result )
> >
> &
> Curious as to why you say you avoid mysql_fetch_array() like the plague. I
> use it frequently and am wondering if there is something wrong/not secure
> when using it or if there is a huge amount of overhead associated with its
> use.
It's not that it's not secure, just that it's bad to use any
Jon, et al --
...and then Jon Kriek said...
%
% Ignatius, the original poster mentioned "an associative array" - The
[snip]
The original poster actually mentioned an associative array with one db
field as the index and another as the value. None of these, just like
Ignatius's suggestion, will d
Devon --
...and then Devon said...
%
...
% SELECT id, name FROM a_table;
%
% I just cannot figure out how to get that data from the resource handle
% into an associative array with the 'id' colomn making up the keys and
% the 'name' colomn making up the values.
You won't get that directly;
Chris, we think along the same lines - posted a similar concern seconds
before you.
--
Jon Kriek
http://phpfreaks.com
"Chris Boget" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > mysql_fetch_array( $result )
>
> Actually, for an associative array (which the OP had made refere
> mysql_fetch_array( $result )
Actually, for an associative array (which the OP had made reference
to), you use mysql_fetch_assoc().
I avoid mysql_fetch_array() like the plague unless there is a very
specific need.
Chris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit:
Ignatius, the original poster mentioned "an associative array" - The
mysql_fetch_assoc() function fetches an associative array. If you want only
that, use that function, if you want indices, use the mysql_fetch_row()
function. If for some reason you need both, then you should use the
mysql_fetch_ar
$qry = "SELECT id, name FROM a_table";
$result = mysql_query($qry) or die(mysql_error());
while ($rs = mysql_fetch_row($result)) {
$myarray[$rs[0]] = $rs[1];
}
is that waht you need?
hth
Jeff
From: "Devon" <[EMAIL PROTECTED]>
> I have been scouring the online documentation and experimenting for
> hours trying to find a solution. I just can't do it.
>
> I have two colomns of data that I am retrieving from MySQL:
>
>SELECT id, name FROM a_table;
>
> I just cannot figure out how
mysql_fetch_array( $result )
_
- Original Message -
From: "Devon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 20, 2003 3:30 PM
Subject: [PHP-DB] Using two colomns of mysql data as key/value pairs in
arrays
> I have been scouring the online do
35 matches
Mail list logo