Re: [PHP-DB] how to reuse DB results

2004-05-20 Thread John W. Holmes
Aaron Wolski wrote:
Is there any way I can make a call to the DB for some records.
 Display some info from a column or two say at the top of the page and
then display the full result set in a while() loop?
Look for the seek() function of whatever database you're using, i.e. 
mysql_data_seek() to reset the results set.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] how to reuse DB results

2004-05-20 Thread Hutchins, Richard
Yeah, that's kind of what I was thinking. The logic in your pseudocode seems
correct. However, I'm not sure about the bit where you do:

$resultset[] = $results

Not because it's wrong, just because I always have to refer back to some
form of documentation when putting result sets into an array to make sure
I'm doing it right because PHP has that whole Resource thingy (I can see you
all cringing now) that represents result sets. Seems to me there's a little
more to it than what's written out above. But I'm certain it's possible to
put a result set right into an array. And once you have that, you can echo()
out whatever members of the array you want and the reset() function will
reset the array pointer to the beginning allowing you to loop through the
array and echo out the results.

Give it a go though, this can't be too far off.

Rich
> -Original Message-
> From: Aaron Wolski [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 20, 2004 4:26 PM
> To: 'Hutchins, Richard'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] how to reuse DB results
> 
> 
> Hi Richard!
> 
> Thanks.
> 
> Ok.. let me see if I got this straight
> 
> Db_query...
> While($results)
> {
> 
>   $resultset[] = $results;
> 
> }
> 
> //display initial data needed
> echo "{$resultset[0]} {"{$resultset[3]}";
> 
> //display full results further down page
> reset($resultset);
> 
> while($resultset)
> {
> 
>   //display full result set here
> 
> }
> 
> 
> Is my logic right or completely off base?
> 
> Thanks!
> 
> A
> 
> 
> 
> > -Original Message-
> > From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
> > Sent: May 20, 2004 4:19 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [PHP-DB] how to reuse DB results
> > 
> > Off the top of my head, you could do the db call once, 
> assign the full
> > result set to an array, pull off the parts you want at the 
> top of the
> > page,
> > then use reset($arrayname) to put the pointer back to the 
> beginning of
> the
> > array then use a loop to print out the whole thing at the bottom of
> the
> > page.
> > 
> > That's just one way though. There are probably others available with
> and
> > without the use of a db abstraction class.
> > 
> > HTH,
> > Rich
> > 
> > > -Original Message-
> > > From: Aaron Wolski [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, May 20, 2004 4:14 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP-DB] how to reuse DB results
> > >
> > >
> > > Hi All,
> > >
> > > Got this logic problem I don't know how to solve.
> > >
> > > Is there any way I can make a call to the DB for some records.
> > >
> > > Display some info from a column or two say at the top of the page
> and
> > > then display the full result set in a while() loop?
> > >
> > > Right now, I am making two calls to the Db to get the 
> data I need to
> > > display at the top of the page and then a second query to retrieve
> the
> > > full result set.
> > >
> > > I'm confused!
> > >
> > > Thanks for any help!
> > >
> > > Aaron
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > 
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> > 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



Re: [PHP-DB] how to reuse DB results

2004-05-20 Thread Cal Evans
adodb has a moveFirst() function. You should be able to use it to 
display x rows then $rs->moveFirst() and then use a while loop to 
display all of them.

HTH,
=C=
:
: Cal Evans
: Evans Internet Construction Company
: 615-260-3385
: http://www.eicc.com
: Building web sites that build your business
:
Aaron Wolski wrote:
Hi All,
Got this logic problem I don't know how to solve.
Is there any way I can make a call to the DB for some records.
Display some info from a column or two say at the top of the page and
then display the full result set in a while() loop?
Right now, I am making two calls to the Db to get the data I need to
display at the top of the page and then a second query to retrieve the
full result set.
I'm confused!
Thanks for any help!
Aaron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] how to reuse DB results

2004-05-20 Thread Aaron Wolski
Hi Richard!

Thanks.

Ok.. let me see if I got this straight

Db_query...
While($results)
{

$resultset[] = $results;

}

//display initial data needed
echo "{$resultset[0]} {"{$resultset[3]}";

//display full results further down page
reset($resultset);

while($resultset)
{

//display full result set here

}


Is my logic right or completely off base?

Thanks!

A



> -Original Message-
> From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
> Sent: May 20, 2004 4:19 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] how to reuse DB results
> 
> Off the top of my head, you could do the db call once, assign the full
> result set to an array, pull off the parts you want at the top of the
> page,
> then use reset($arrayname) to put the pointer back to the beginning of
the
> array then use a loop to print out the whole thing at the bottom of
the
> page.
> 
> That's just one way though. There are probably others available with
and
> without the use of a db abstraction class.
> 
> HTH,
> Rich
> 
> > -Original Message-
> > From: Aaron Wolski [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, May 20, 2004 4:14 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-DB] how to reuse DB results
> >
> >
> > Hi All,
> >
> > Got this logic problem I don't know how to solve.
> >
> > Is there any way I can make a call to the DB for some records.
> >
> > Display some info from a column or two say at the top of the page
and
> > then display the full result set in a while() loop?
> >
> > Right now, I am making two calls to the Db to get the data I need to
> > display at the top of the page and then a second query to retrieve
the
> > full result set.
> >
> > I'm confused!
> >
> > Thanks for any help!
> >
> > Aaron
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP-DB] how to reuse DB results

2004-05-20 Thread Hutchins, Richard
Off the top of my head, you could do the db call once, assign the full
result set to an array, pull off the parts you want at the top of the page,
then use reset($arrayname) to put the pointer back to the beginning of the
array then use a loop to print out the whole thing at the bottom of the
page.

That's just one way though. There are probably others available with and
without the use of a db abstraction class.

HTH,
Rich

> -Original Message-
> From: Aaron Wolski [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 20, 2004 4:14 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] how to reuse DB results
> 
> 
> Hi All,
> 
> Got this logic problem I don't know how to solve.
> 
> Is there any way I can make a call to the DB for some records.
> 
> Display some info from a column or two say at the top of the page and
> then display the full result set in a while() loop?
> 
> Right now, I am making two calls to the Db to get the data I need to
> display at the top of the page and then a second query to retrieve the
> full result set.
> 
> I'm confused!
> 
> Thanks for any help!
> 
> Aaron
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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