如何将评论,喜欢,分享,时间选项显示为facebook?
我创建了一个类似于 Facebook 的帖子系统,如下图所示[感谢 SO 的人]:
我无法正确放置内容。在哪里以及如何调整?
我希望它看起来类似于 Facebook 的帖子部分。
如何显示评论,喜欢,分享选项如上?
代码:index.php:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#submit').on('click',function(e){
e.preventDefault();
input=$('#message').val();
var comment={};
comment.input=input;
var commentdata=$("message").val();
$.ajax({
type: "POST",
data:{
comment: commentdata
},
url: "ajax.php",
success: function(data, textStatus){
//alert(data);
$("#commentsholder").append(data);
$('#comments').append(comment.input);
}
},'html');
});
});
</script>
</head>
<body>
<lable>Add post </lable><br>
<textarea id="message" rows="4" cols="50" placeholder="Add post"> </textarea>
<input type="submit" id="submit" value="share"> </input>
<div>
<div id="commentsholder"></div>
<ul id="comments" ></ul>
</div>
</body>
</html>
ajax.php:
<?php
$comment=$_POST['commentdata'];
$con = mysqli_connect('127.0.0.1:3306', 'root', 'root', 'test');
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query= "select * from user_record where id=100005809179068";
$result = mysqli_query($con,$query);
//build html format as you need it..
while($row = mysqli_fetch_array($result)){
echo '<div class="comment"><img src="'.$row ['picture'].'"/>'.$row ['name'].'</div>';
}
?>