i want to show information against the click on different images, want to fetch information from database
anyone can help me???
like when someone click on the image the information against it should visible on the same page from database

Recommended Answers

All 2 Replies

Use AJAX and onclick event handler on image tag.

Check the following example

Your listing page

<script src="//code.jquery.com/jquery-1.10.2.js"></script>

<img class="img_btn" alt="Image 1" rel="1" src="img1.jpg" /><br />
<img class="img_btn" alt="Image 2" rel="2" src="img2.jpg" /><br />
<img class="img_btn" alt="Image 3" rel="3" src="img3.jpg" />
<div class="result">

</div>

<script type="text/javascript">
$(function() {
    $(".img_btn").click(function() {
        $.post('request.php',{id: $(this).attr('rel')}, function(data) {
            if(data) $(".result").html(data);
            else $(".result").html("");

        });
    });
});
</script>

In request.php

<?php
$image_Id = $_POST['id'];

//here you fetch the the result related with image id from mysql and print the result

echo '<h1>You Selected '.$image_Id.'</h1>';
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.