當前我正在嘗試使用CodeIgniter以在用戶輸入後顯示評論或帖子,並且在不刷新頁面的情況下顯示它。CodeIgniter - 從MySQL中檢索數據並在不刷新頁面的情況下進行顯示
我一直在尋找答案几天,我仍然無法爲我的項目得到任何合適的答案。
不好意思說我還在使用CodeIgniter和JQuery。因爲這個項目的目標是希望我們學習新的編程語言。
這是我認爲的代碼,我提取主代碼
<?php
foreach ($comment as $comments) {
if ($comments['PostID'] == $stickynote['PostID']) {
?>
<div style="background-color: lightblue; border-radius: 5px 5px 5px 5px; margin-bottom: 5px; width: 70%; height: 80px">
<a class="pull-left" href="#">
<!-- Profile Picture -->
<img style='margin-top: 9px; margin-left: 5px; border-radius: 5px; padding-left: 5px;' class="media-object" id="sub-photo" src="../../images/<?php echo $profile ?>" alt="<?php echo $profile ?>" alt="...">
</a>
<div class="media-body">
<!-- Display Username -->
<h4 class="media-heading"><?php echo $comments['FirstName'] ?></h4>
<p style="width: 500px; word-wrap:break-word;">
<?php echo $comments['Description'] ?>
</p>
</div>
</div>
<?php
} <!-- End of IF statement -->
} <!-- End of FOR LOOP -->
?>
這是我的控制器
這是我的模型
public function readComment($studentID) {
$this -> db -> select('PostID, Description, FirstName, LastName, PostTime, Image');
$this -> db -> from('Comment');
$this -> db -> join('CollegeUser', 'CollegeUser.StudentID = Comment.StudentID');
$this -> db -> join('PhotoGallery', 'PhotoGallery.PhotoID = CollegeUser.PhotoID');
$this -> db -> order_by("Comment.PostTime", "desc");
return $this -> db -> get() -> result_array();
}
感謝您的誰幫助我。歡呼。
由用戶輸入??你的表單在哪裏,用戶可以輸入評論? – bipen
學習'Ajax'第一個隊友,這裏有一些鏈接:1)http://www.w3schools.com/ajax/,2)http://api.jquery.com/category/ajax/ –
@Bipen,實際上是一個form_open()在那裏。但我沒有展示出來。抱歉。 – Blackie