RE: how to reuse DB results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:aaronjw@xxxxxxxxxxxxx]
> Sent: Thursday, May 20, 2004 4:26 PM
> To: 'Hutchins, Richard'; php-db@xxxxxxxxxxxxx
> Subject: RE:  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:Richard.Hutchins@xxxxxxxxxxxxxx]
> > Sent: May 20, 2004 4:19 PM
> > To: php-db@xxxxxxxxxxxxx
> > Subject: RE:  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:aaronjw@xxxxxxxxxxxxx]
> > > Sent: Thursday, May 20, 2004 4:14 PM
> > > To: php-db@xxxxxxxxxxxxx
> > > Subject:  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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux