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 8263681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:11:27+00:00 2026-06-08T04:11:27+00:00

I’m trying to make a function kinda similar to facebook’s notification window. Their function

  • 0

I’m trying to make a function kinda similar to facebook’s notification window. Their function seems to combine any kind of event and display them after date.

So i have 2 tables :
Article and comments.
both have 2 similar rows : uniquepostowner and date_posted.

I want to join them up and display them one after another.
Example :

User A has posted a comment (04.05.2012 5:30)
User B Has posted a comment (04.05.2012 6:30)
User C has written an article (04.05.2012 7:30)
user D has posted a comment (04.05.2012 8:30)

However, i’m struggling with both joining these 2 and displaying the results.
Reading others with similar scenarios ive tried this as a query:

$sesid = $_SESSION['user_id'];
$sql = "SELECT X.* FROM ( SELECT * FROM `article` WHERE uniquepostowner = {$sesid} UNION SELECT * FROM `comments`  WHERE uniquepostowner  = {$sesid} ) X ORDER BY X.`date_posted`";
$result = mysql_query($sql);

Then trying to fetch the results like this:

while($row = mysql_fetch_array($result))
{
echo $row['article.id'];
 }   

Tables:

**article**:
id
title
content
uniqueuser
date_posted
full_name
uniquepostowner

**comments**:
id 
pid (same as article.id)
date_posted
content
full_name
uniquepostowner

there are more rows to these tables, but they are irrelevant.
But no success. Any help is greatly appreciated as always! 🙂

Currently i’m trying this, but its not doing what i want.

$sql = "SELECT * FROM article a INNER JOIN comments c WHERE a.uniquepostowner = {$sesid} AND c.uniquepostowner = {$sesid} 
ORDER BY a.date_posted DESC , c.date_posted DESC ";
  • 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-06-08T04:11:29+00:00Added an answer on June 8, 2026 at 4:11 am

    I think this is what you need:

    UPDATED:

    $sesid = $_SESSION['user_id'];
    $sql = "
    SELECT 
        X . *
    FROM
        (SELECT 
            id,
            date_posted,
            content,
            full_name,
            uniquepostowner,
            'article' AS type
        FROM
            article
        WHERE
            uniquepostowner = {$sesid} UNION SELECT 
            id,
            date_posted,
            content,
            full_name,
            uniquepostowner,
            'comment' AS type
        FROM
            comments
        WHERE
            uniquepostowner = {$sesid}) X
    ORDER BY X.date_posted
    ";
    $result = mysql_query($sql);
    

    And you can iterate with:

    while($row = mysql_fetch_array($result))
    {
            if($row['type']=='article'){
                echo "User " . $row['full_name'] . " has written an article (".$row['date_posted'].")<br>";
            } else {
                echo "User " . $row['full_name'] . " has posted a comment (".$row['date_posted'].")<br>";
            }
    }
    

    You can check it out at:

    http://sqlfiddle.com/#!2/38778/8

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.