Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need to make a moderate system like the one in fmylife.com. Basically the problem I have is loading the MySQL query using Ajax (without page refreshing) in to a div. MySQL query

$sql = mysql_query(“SELECT * FROM posts WHERE active =’0’” LIMIT 1) or die (mysql_error());
$row = mysql_fetch_array($sql);

HTML

<div class=”post-body”><?php echo $row[‘sitepost’];?></div>

this data should be reloaded when pressing "yes" or "no" buttons. thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
681 views
Welcome To Ask or Share your Answers For Others

1 Answer

in post.php:

$sql = mysql_query("SELECT * FROM posts WHERE active ='0' LIMIT 1") or die (mysql_error());
$row = mysql_fetch_array($sql);
echo $row['sitepost'];

JS:

<script type="text/javascript">
$(document).ready(function(){
   $("#yes").click(function(){
      $(".post-body").eq(0).load("post.php");
   })
})
</script>

HTML:

<div id="yes">YES</div>
<div class="post-body"></div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...