php to Navigate Through Records

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
millsy007
Forum Commoner
Posts: 78
Joined: Wed Jul 02, 2008 7:00 pm

php to Navigate Through Records

Post by millsy007 »

I have some code (http://devzone.zend.com/article/3336-Re ... s-with-PHP) that read the contents of an excel spreadsheet and then puts this into an array.

I have it so that it outputs the contents of the array onto the screen, what I would really like is for it to only show one record from the array at a time, and for the user to then click a 'next' to see the next record within the array, preferably without having to reload the whole page

Is there a way to do this, perhaps with a combination of css and php.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: php to Navigate Through Records

Post by califdon »

millsy007 wrote:I have some code (http://devzone.zend.com/article/3336-Re ... s-with-PHP) that read the contents of an excel spreadsheet and then puts this into an array.

I have it so that it outputs the contents of the array onto the screen, what I would really like is for it to only show one record from the array at a time, and for the user to then click a 'next' to see the next record within the array, preferably without having to reload the whole page

Is there a way to do this, perhaps with a combination of css and php.
You would probably want to do this with Javascript, because to do it with php you would need to use $_SESSION variables to achieve persistence from one call to the next. I guess that could be done, but if your array is very large, there might be a problem with server memory. Anyone know what limits there may be?
millsy007
Forum Commoner
Posts: 78
Joined: Wed Jul 02, 2008 7:00 pm

Re: php to Navigate Through Records

Post by millsy007 »

It would probably be around 10-15 records (each containing a few lines of text) so memory shouldnt be an issue.

I think javascript is the way forward, I have found fairly similar things around image galleries, however I basically need to cycle through content.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: php to Navigate Through Records

Post by califdon »

millsy007 wrote:It would probably be around 10-15 records (each containing a few lines of text) so memory shouldnt be an issue.

I think javascript is the way forward, I have found fairly similar things around image galleries, however I basically need to cycle through content.
That being the case, I will move this topic to Client Side.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: php to Navigate Through Records

Post by Ollie Saunders »

Simple technique would be:
  • Output the whole thing with the starting item identified by a class

    Code: Select all

    <ul id="munchkin">
      <li>foo</li>
      <li class="show">bar</li>
      <li>zim</li>
    </ul>
  • Use CSS to hide everything except the show
  • Add some JS that runs when some hyperlinks, elsewhere in the markup, are clicked. jQuery is good for that :-)
Also note that what you are attempting to implement it called an "accordion" or "carousel" depending on how you make it look. So you could google for them to see some examples.
Post Reply