PHP/MySQL - Load More Data on Click

Posted on 2010-01-05
Last Modified: 2013-12-13

i have a table in my db that contains text and 5 images. on the page load i only want the text and one image to be displayed. then when the image is clicked on the remaining four images are displayed with the original content. i have pulled the  text and image. I dont know how to go about loading the rest of the images on click.

Any advice would be helpful.
Question by:davidcairns90
    LVL 9

    Expert Comment

    I think if it's only 5 images, that the best way to do this is using javascript and css.

    You hide the others 4 text and images and at the event onClick of your 1st image you show the rest.

    Author Comment


    i have very limited knowledge of javascript. is it possible to elaborate on this
    LVL 9

    Accepted Solution

    It would be something like this:

    <script type="text/javascript">
    function showOthers() {
    	var myDiv = document.getElementById('others'); = 'visible'; = 'block';
    <div id="first">
    My 1st text and image... <img src='teste.gif' onClick='showOthers()'>
    <div id="others" style="visibility: hidden; display: none;">
    My 2nd text and image... <img src='test2.gif'><br><br>
    My 3rd text and image... <img src='test2.gif'><br><br>
    My 4th text and image... <img src='test2.gif'><br><br>
    My 5th text and image... <img src='test2.gif'><br><br>

    Open in new window


    Author Closing Comment

    Thank you. worked like a dream

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    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…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now