Thursday, 12 May 2016

Create News Feed In PHP

Code To Create A Simple News Feed In PHP

Use Ajax & Jquery To Fetch & Populate News Feed . Make Ajax Call From Page Control Will go to specified PHP page through ajax call then fetch data in that PHP page and send data to callback to Ajax Call

See A simple Example below :-


//Required CSS  / JSS Files
<div id="news"></div>
//Click Button Below To Fetch News Feeds
<input type="button" onclick="GetNews()" value="Get News Feed" />
    function GetNews()

AjaxFetchData.php File Code

//Sql Query To Fetch News Feed From Database
$con= Initialize it with connection Details for database
$sql = "Select Top 50 from TblNews";
$result = $result=mysqli_query($con,$sql);
while($row =  $result->fetch_assoc())
    echo("<div class='NewsFeed'>");
    echo("<div class='title'>" . $row['title'] . "</div>");
    echo("<div class='body'>" . $row['body'] . "</div>");


Share this

0 Comment to "Create News Feed In PHP"

Post a Comment