Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:02:22+00:00 2026-05-26T23:02:22+00:00

I have an information system, more specifically an information system that is a ticketing

  • 0

I have an information system, more specifically an information system that is a ticketing system. The info system will contain accounts that will have an infinite or ‘n’ amount of users. I want users to be able to see other users actions or changes to content in a newsfeed. (Just like Facebook). I will be using PHP, MySQL, and AJAX (or jQuery) to implement the newsfeed. I will know how to setup the tables and queries.

How do I use PHP and AJAX or jQuery to pull the content and display it in the newsfeed (in Facebook newsfeed style with either the fade or scroll effect?).

I have been searching for a good tutorial and have not found one. I would like to preferably code this from scratch if possible.

I’m still having a few issues: Here is what I have:

ajax.php

<?php require_once('../../Connections/f12_database_connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_f12_database_connect, $f12_database_connect);
$query_newsfeed_a = "SELECT * FROM newsfeed";
$newsfeed_a = mysql_query($query_newsfeed_a, $f12_database_connect) or die(mysql_error());


while($row_newsfeed_a = mysql_fetch_assoc($newsfeed_a))
{
        echo("<div class='feedItem'>");
    echo("<div class='title'>" . $feedItem['title'] . "</div>");
    echo("<div class='body'>" . $feedItem['body'] . "</div>");
    echo("</div>");



}
$totalRows_newsfeed_a = mysql_num_rows($newsfeed_a);
?>

<?php
mysql_free_result($newsfeed_a);
?>

feed.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>

<script>
    function refreshNews()
    {
        $("#news").load("ajax.php")
    }
</script>
</head>

<body>





<div id="news"></div>
</body>
</html>

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:02:23+00:00Added an answer on May 26, 2026 at 11:02 pm

    If you want to code it from scratch the basic process is to create a PHP script that gathers the data and sends it back to the AJAX request. Usually I create a separate PHP file that handles whatever operation I need.

    Anything that your PHP script would normally output is sent back to the AJAX request. So any HTML tags, any echo / print statements. Things like header() create output as well, just a warning.

    Depending on the design of the page, you can create the HTML in PHP and then use jQuery to put that html into the page as needed. Another option is to use PHP’s json_encode() and send all the data back as JSON and build the HTML structure client side.

    If each feed item is going to have the same basic structure, then it’s probably easiest to create the HTML server side in the PHP like you would for any regular page. You only need the HTML code snippet that is the feed.

    The simplest method would be jQuery.load()
    http://api.jquery.com/load/

    Inside the HTML Page:

    <script>
        function refreshNews()
        {
            $("#news").load("path/to/ajax.php")
        }
    </script>
    
    <div id="news"></div>
    

    In PHP:

    $sql = "SQL TO GET NEWS FEED";
    
    $result = mysql_query($sql);
    
    while($feedItem = mysql_fetch_assoc($result))
    {
        echo("<div class='feedItem'>");
        echo("<div class='title'>" . $feedItem['title'] . "</div>");
        echo("<div class='body'>" . $feedItem['body'] . "</div>");
        echo("</div>");
    }
    

    Then you can call refreshNews() from another event (refresh button, timed event, etc.).

    Obviously your html and data structure may be different. Just make sure this is the only thing this PHP file outputs. This includes anything outside the tags.

    There are more efficient ways of doing this, this script would essentially reload the entire list of news items on each call to refreshNews(). For now this is one of the easiest ways to get it working, so try it out and if need be there are more efficient ways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a system I am trying to design that will retrieve information from
I have an as400 system that stores all information about our articles, like price,
I have a system that logs information and sometimes find a particular IP address
I have information spread out across a few databases and want to put all
I have an information retrieval application that creates bit arrays on the order of
I have some information in my database like 'author', 'book' etc., that are all
I need to have some information about the scoping in JavaScript. I know that
I have a bunch of perfmon files that have captured information over a period
I am using JACOB to access system information through WMI. I have not found
I have an app that accesses information about websites running on IIS on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.