Re: [PHP-DB] How to get only 2nd row in result set ???

2004-04-05 Thread Kim Steinhaug
DOH! - A private message arrived read below

When you mention it, ofcourse this is the correct (and sane sollution). I
guess
I was giving more flesh to the bone that the previous poster posted.

Looping through when limit is there is plain and simple stupid...

Shame on me! :)

Kim Steinhaug


- Original Message - 
From: "Ross Honniball" 
To: "Kim Steinhaug" <[EMAIL PROTECTED]>
Sent: Monday, April 05, 2004 4:18 AM
Subject: Re: [PHP-DB] How to get only 2nd row in result set ???


> If you specify LIMIT 2,1 then this will only return 1 record (ie. the
> second parameter is the number of results to return)
>
> At 06:17 AM 5/04/2004, you wrote:
> >I would say the same, do the query and then a loop through the results.
> >Skip the first one and output the second,
> >
> >eg.
> >
> >$levels = mysql_query("SELECT levelID from hf_levels ORDER BY levelorder
> > > RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());
> >for($i=0;$i >  $item = mysql_fetch_object($levels);
> >  if($i){
> >  // Do the output with the new object, $item
> >  break;
> >  }
> >}
> >
> >
> >--
> >--
> >Kim Steinhaug
> >--
> >There are 10 types of people when it comes to binary numbers:
> >those who understand them, and those who don't.
> >--
> >www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
> >--
> >
> >"Mikhail U. Petrov" <[EMAIL PROTECTED]> wrote in message
> >news:[EMAIL PROTECTED]
> > > Hi!
> > > But what's the problem?
> > > You can use mysql_fetch_array() 2 times.
> > > But may be I understood question not correctly...
> > >
> > >
> > > Friday, April 2, 2004, 10:06:05 PM, -{ wrote:
> > >
> > > RB> I couldn't find anything like this from my archive searches ... so
> >here goes:
> > >
> > > RB> I've got this query:
> > >
> > > RB> $levels = mysql_query("SELECT levelID from hf_levels ORDER BY
> >levelorder
> > > RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());
> > >
> > > RB> but I can't figure out how to write the rest of the code ... I
need to
> >skip
> > > RB> the first row and get the data from the 2nd row... but because
there's
> >an
> > > RB> optional up to 255 possible rows in this table, and the order of
these
> >are
> > > RB> determined by a user customizable field called levelorder ... so I
> >can't
> > > RB> just pick the specific numrows - 1 ... :-/
> > >
> > > RB> I know this is a kludge to do it this way ... but it's what I need
for
> >now
> > > RB> ... later I'll get to do it a more brilliant way...
> > >
> > >
> > > RB> TIA
> > >
> > > RB> Rene
> > > RB> --
> > > RB> Rene Brehmer
> > > RB> aka Metalbunny
> > >
> > > RB> ~ If you don't like what I have to say ... don't read it ~
> > >
> > > RB> http://metalbunny.net/
> > > RB> References, tools, and other useful stuff...
> > > RB> Check out the new Metalbunny forums @
http://forums.metalbunny.net/
> > >
> > >
> > >
> > > --
> > > Best regards,
> > > Mikhail U. Petrov
> > > mailto:[EMAIL PROTECTED]
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> . Ross Honniball  JCU Bookshop Cairns Supervisor
> . James Cook Uni, McGreggor Rd, Smithfield, Qld. 4878, Australia
> . Ph:07.4042.1157  Fx:07.4042.1158   Em:[EMAIL PROTECTED]
> . There are no problems. Only solutions.
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP-DB] How to get only 2nd row in result set ???

2004-04-04 Thread Aitziber Hernández

KS>  $item = mysql_fetch_object($levels);
probe with  $item = mysql_fetch_rows($levels);

 
 Aitzi

[EMAIL PROTECTED]

->-
domingo, 04 de abril de 2004, 22:17:41, escribiste:

KS> I would say the same, do the query and then a loop through the results.
KS> Skip the first one and output the second,

KS> eg.

KS> $levels = mysql_query("SELECT levelID from hf_levels ORDER BY levelorder
>> RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());
KS> for($i=0;$i  $item = mysql_fetch_object($levels);
KS>  if($i){
KS>  // Do the output with the new object, $item
KS>  break;
KS>  }
KS> }


KS> -- 
KS> -- 
KS> Kim Steinhaug
KS> --
KS> There are 10 types of people when it comes to binary numbers:
KS> those who understand them, and those who don't.
KS> --
KS> www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
KS> --

KS> "Mikhail U. Petrov" <[EMAIL PROTECTED]> wrote in message
KS> news:[EMAIL PROTECTED]
>> Hi!
>> But what's the problem?
>> You can use mysql_fetch_array() 2 times.
>> But may be I understood question not correctly...
>>
>>
>> Friday, April 2, 2004, 10:06:05 PM, -{ wrote:
>>
>> RB> I couldn't find anything like this from my archive searches ... so
KS> here goes:
>>
>> RB> I've got this query:
>>
>> RB> $levels = mysql_query("SELECT levelID from hf_levels ORDER BY
KS> levelorder
>> RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());
>>
>> RB> but I can't figure out how to write the rest of the code ... I need to
KS> skip
>> RB> the first row and get the data from the 2nd row... but because there's
KS> an
>> RB> optional up to 255 possible rows in this table, and the order of these
KS> are
>> RB> determined by a user customizable field called levelorder ... so I
KS> can't
>> RB> just pick the specific numrows - 1 ... :-/
>>
>> RB> I know this is a kludge to do it this way ... but it's what I need for
KS> now
>> RB> ... later I'll get to do it a more brilliant way...
>>
>>
>> RB> TIA
>>
>> RB> Rene
>> RB> -- 
>> RB> Rene Brehmer
>> RB> aka Metalbunny
>>
>> RB> ~ If you don't like what I have to say ... don't read it ~
>>
>> RB> http://metalbunny.net/
>> RB> References, tools, and other useful stuff...
>> RB> Check out the new Metalbunny forums @ http://forums.metalbunny.net/
>>
>>
>>
>> -- 
>> Best regards,
>> Mikhail U. Petrov
>> mailto:[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] How to get only 2nd row in result set ???

2004-04-04 Thread Kim Steinhaug
I would say the same, do the query and then a loop through the results.
Skip the first one and output the second,

eg.

$levels = mysql_query("SELECT levelID from hf_levels ORDER BY levelorder
> RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());
for($i=0;$i wrote in message
news:[EMAIL PROTECTED]
> Hi!
> But what's the problem?
> You can use mysql_fetch_array() 2 times.
> But may be I understood question not correctly...
>
>
> Friday, April 2, 2004, 10:06:05 PM, -{ wrote:
>
> RB> I couldn't find anything like this from my archive searches ... so
here goes:
>
> RB> I've got this query:
>
> RB> $levels = mysql_query("SELECT levelID from hf_levels ORDER BY
levelorder
> RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());
>
> RB> but I can't figure out how to write the rest of the code ... I need to
skip
> RB> the first row and get the data from the 2nd row... but because there's
an
> RB> optional up to 255 possible rows in this table, and the order of these
are
> RB> determined by a user customizable field called levelorder ... so I
can't
> RB> just pick the specific numrows - 1 ... :-/
>
> RB> I know this is a kludge to do it this way ... but it's what I need for
now
> RB> ... later I'll get to do it a more brilliant way...
>
>
> RB> TIA
>
> RB> Rene
> RB> -- 
> RB> Rene Brehmer
> RB> aka Metalbunny
>
> RB> ~ If you don't like what I have to say ... don't read it ~
>
> RB> http://metalbunny.net/
> RB> References, tools, and other useful stuff...
> RB> Check out the new Metalbunny forums @ http://forums.metalbunny.net/
>
>
>
> -- 
> Best regards,
> Mikhail U. Petrov
> mailto:[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] How to get only 2nd row in result set ???

2004-04-02 Thread Rogers, Dennis
This will give you the second row of data.

$levels = mysql_query("SELECT levelID "
."from hf_levels "
."ORDER BY levelorder " 
."DESC LIMIT 1, 1") or die('Unable to get
levels'.mysql_error());



-Original Message-
From: Mikhail U. Petrov [mailto:[EMAIL PROTECTED]
Sent: Friday, April 02, 2004 12:16 PM
To: -{ Rene Brehmer }-
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] How to get only 2nd row in result set ???


Hi!
But what's the problem?
You can use mysql_fetch_array() 2 times.
But may be I understood question not correctly...


Friday, April 2, 2004, 10:06:05 PM, -{ wrote:

RB> I couldn't find anything like this from my archive searches ... so here
goes:

RB> I've got this query:

RB> $levels = mysql_query("SELECT levelID from hf_levels ORDER BY levelorder

RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());

RB> but I can't figure out how to write the rest of the code ... I need to
skip 
RB> the first row and get the data from the 2nd row... but because there's
an 
RB> optional up to 255 possible rows in this table, and the order of these
are 
RB> determined by a user customizable field called levelorder ... so I can't

RB> just pick the specific numrows - 1 ... :-/

RB> I know this is a kludge to do it this way ... but it's what I need for
now 
RB> ... later I'll get to do it a more brilliant way...


RB> TIA

RB> Rene
RB> -- 
RB> Rene Brehmer
RB> aka Metalbunny

RB> ~ If you don't like what I have to say ... don't read it ~

RB> http://metalbunny.net/
RB> References, tools, and other useful stuff...
RB> Check out the new Metalbunny forums @ http://forums.metalbunny.net/



-- 
Best regards,
Mikhail U. Petrov
mailto:[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] How to get only 2nd row in result set ???

2004-04-02 Thread Mikhail U. Petrov
Hi!
But what's the problem?
You can use mysql_fetch_array() 2 times.
But may be I understood question not correctly...


Friday, April 2, 2004, 10:06:05 PM, -{ wrote:

RB> I couldn't find anything like this from my archive searches ... so here goes:

RB> I've got this query:

RB> $levels = mysql_query("SELECT levelID from hf_levels ORDER BY levelorder 
RB> DESC LIMIT 2") or die('Unable to get levels'.mysql_error());

RB> but I can't figure out how to write the rest of the code ... I need to skip 
RB> the first row and get the data from the 2nd row... but because there's an 
RB> optional up to 255 possible rows in this table, and the order of these are 
RB> determined by a user customizable field called levelorder ... so I can't 
RB> just pick the specific numrows - 1 ... :-/

RB> I know this is a kludge to do it this way ... but it's what I need for now 
RB> ... later I'll get to do it a more brilliant way...


RB> TIA

RB> Rene
RB> -- 
RB> Rene Brehmer
RB> aka Metalbunny

RB> ~ If you don't like what I have to say ... don't read it ~

RB> http://metalbunny.net/
RB> References, tools, and other useful stuff...
RB> Check out the new Metalbunny forums @ http://forums.metalbunny.net/



-- 
Best regards,
Mikhail U. Petrov
mailto:[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] How to get only 2nd row in result set ???

2004-04-02 Thread -{ Rene Brehmer }-
I couldn't find anything like this from my archive searches ... so here goes:

I've got this query:

$levels = mysql_query("SELECT levelID from hf_levels ORDER BY levelorder 
DESC LIMIT 2") or die('Unable to get levels'.mysql_error());

but I can't figure out how to write the rest of the code ... I need to skip 
the first row and get the data from the 2nd row... but because there's an 
optional up to 255 possible rows in this table, and the order of these are 
determined by a user customizable field called levelorder ... so I can't 
just pick the specific numrows - 1 ... :-/

I know this is a kludge to do it this way ... but it's what I need for now 
... later I'll get to do it a more brilliant way...

TIA

Rene
--
Rene Brehmer
aka Metalbunny
~ If you don't like what I have to say ... don't read it ~

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums @ http://forums.metalbunny.net/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php