0

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

3
Contributors
2
Replies
14
Views
3 Years
Discussion Span
Last Post by Bachu
0

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>';
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.