Reputation:
I want that if i click on an anchor tag it shows the mysql database table values
for example
<a href"#">Click to show comments</a>
after clicking
it will do something like this
SELECT * FROM `comments`LIMIT 0 , 30
Upvotes: 1
Views: 2136
Reputation: 27313
I think you would need to use AJAX, I advice you to use jQuery for this purpose.
using jquery you would have to do something like
in your HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<a id="foobar "href="#">Click to show comments</a>
<div id="comments"></div>
<script>
$(document).ready(function(){
$('#id').click(function(){
$.ajax({
url: "comment.php",
dataType: 'json',
success: function(data){
foreach(v in data) {
$('#comments').append(data[v]);
}
}
});
});
});
You would have to put together the comment.php script that would output the data retrieved from the database and use json_encode to encode it in JSON
Upvotes: 2