I have a for loop that is echoing values out of the database, anyway to pause in-between listings?

Each loop echos about a 3 sentence entry. The problem is it sometimes just fills the screen with them. I'd like to list each one at a time, followed by a "click here to continue" or similiar statement, then show the next one in the loop. Is that possible?

LVL 10
stormistAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TomeeboyCommented:
There's no way to pause the loop in the middle of its execution and get user input.  You could either load all of the content into the page and then hide/display it (perhaps with a javascript), or use a paging technique to display a link below the current entry that the user could click to reload the page and display the next one (which would involve a new query every time).

It sounds like the best option would be to just break your database query results up using paging techniques and load a certain number of entries at a time (however many you think is an acceptable amount to display at once).  This would still require a database query for every page of entries that the user views, but it would be more efficient than pulling them one at a time.

Hope that helps give you some idea of what to do :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stormistAuthor Commented:
I'm up for learning Javascript soon(ive actually got the books ordered) but for now I really don't know it very well. The hiding idea and revealing when they click sounds really cool. Would it be complicated to code and explain? :)

(hi again tomeeboy. Man between you, Roonan, and Bogo I get most of my problems solved! :) )
0
TomeeboyCommented:
For the javascript show/hide method, I think you'd need to put the content in seperate divs that would have unique id names:

<div id="one"> Your Content </div>
<div id="two" style="display:none"> Your Content #2</div>

Here's some javascript I came across for showing/hiding one or more divs based on their ID:

<script type="text/javascript">

function show()
{
for(var I=0;I<arguments.length;I++)
{
var obj=document.getElementById(arguments[I]);
obj.style.display = '';

}
}
function hide()
{
for(var I=0;I<arguments.length;I++)
{
var obj=document.getElementById(arguments[I]);
obj.style.display = 'none';

}
}
</script>

So your link might look like this:

<a href="#" onClick="hide('one');show('two')">Show Item #2</a>

Haven't tested this for accuracy... it's very late :)  Hopefully gives you some ideas though.
0
TomeeboyCommented:
I still think the paging option would be better, as the javascript method could essentially end up hiding all of your content from somebody who had javascript disabled :)
0
stormistAuthor Commented:
Thx! :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.