Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2006-04-05
5
Medium Priority
?
239 Views
Last Modified: 2008-03-10
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?

0
Comment
Question by:stormist
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Tomeeboy earned 1000 total points
ID: 16389261
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
 
LVL 10

Author Comment

by:stormist
ID: 16389428
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
 
LVL 15

Expert Comment

by:Tomeeboy
ID: 16389609
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
 
LVL 15

Expert Comment

by:Tomeeboy
ID: 16389616
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
 
LVL 10

Author Comment

by:stormist
ID: 16395421
Thx! :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question