ResultSet Problem??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sully
Forum Newbie
Posts: 2
Joined: Fri Feb 07, 2003 3:08 pm
Location: Ireland

ResultSet Problem??

Post by Sully »

Hello All,
I am having alot of trouble trying to append a result set using a loop. I am taking a number from options from a select option list in a form and for each of these i want to execute the statement.

for($y=0; $y<$totaltown; $y++) {
$result=select statement
}

and then out put the info using a while loop.
My problem is the result set keeps overwriting itself until it produces 0 results.
I have tried using $result+=$result but it is then no longer a ersult set. The code i have works fine when i only want to produce all hte results on one page but i am paging the results which is where my problem lies ie LIMIT.

I would appreciate any help as i have hit the wall with it.

Many Thanks
Sully
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

most likely it is not useful to store the result between pages. It would be necessary to save this information e.g. in a session. It's more reasonable to limit the query exactly to the data you need for this request.
e.g. if the user can select the amount of records shown on each page, you might only save the information [X records per page, page #Y] in a hidden field or link and read that information on each request.
Increase Y in your script for the next page and limit the request to only these records.
User avatar
DaZZleD
Forum Commoner
Posts: 38
Joined: Tue Jan 07, 2003 5:39 am

Post by DaZZleD »

if the statement looks like "$result = select statement;" $result will overwrite itself each time the command is run. if you want to append the result use "." like:

$result .= select statement.


however a bit more of your code will help in giving you a better answer.
Post Reply