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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:24:07+00:00 2026-06-04T21:24:07+00:00

I am a beginner at PHP, but have been attempting a project on a

  • 0

I am a beginner at PHP, but have been attempting a project on a forum. I have come across a problem though.

            $getLatest = dbquery("SELECT * FROM site_forum_thread_comments,site_forum_threads,site_forum_subs WHERE site_forum_thread_comments.thread_id=site_forum_threads.thread_id AND 
        site_forum_threads.sub_id=site_forum_subs.sub_id AND
        site_forum_subs.main_id='".$forum['ID']."'
        ORDER BY site_forum_thread_comments.timestamp DESC LIMIT 1");
            while ($latest = mysql_fetch_assoc($getLatest))
                {
                    $getUser = dbquery("SELECT * FROM users WHERE id='".$latest['user_comment_id']."'");
                    while ($user = mysql_fetch_assoc($getUser))
                    {
                            echo ' <BR>Latest Post: '.$latest['comment'].'
                            <BR>User: '.$user['username'].'
                            <BR>Forum: '.substr($latest['site_forum_threads.title'],0,20).'...';
                    }
                }

This is just a snippet of the code. What happens is, $getLatest gets the code from the SQL query which are from a number of different tables in my database.
My problem:
At the last part Forum ‘.substry($latest[‘…blahblahblah’]

Am I able to add the table function in it? So I can retrieve the column “title” from site_forum_threads as I have done it? Because in one of my other tables, there is also a column called “tables”, and the query is getting mixed up between which column it should be getting the data from.

Thanks in advance!

EDIT : @zerkms

$getLatest = dbquery("SELECT * FROM site_forum_thread_comments,site_forum_threads,site_forum_subs 
        site_forum_threads.title AS title_from_site_forum_threads 
        WHERE site_forum_thread_comments.thread_id=site_forum_threads.thread_id AND 
        site_forum_threads.sub_id=site_forum_subs.sub_id AND
        site_forum_subs.main_id='".$forum['ID']."' AND
        side_forum_threads.title= title_from_site_forum_threads
        ORDER BY site_forum_thread_comments.timestamp DESC LIMIT 1");
            while ($latest = mysql_fetch_assoc($getLatest))
                {
                    $getUser = dbquery("SELECT * FROM users WHERE id='".$latest['user_comment_id']."'");
                    while ($user = mysql_fetch_assoc($getUser))
                    {
                            echo ' <BR>Latest Post: '.$latest['comment'].'
                            <BR>User: '.$user['username'].'
                            <BR>Forum: '.substr($latest['title_from_site_forum_threads'],0,20).'...';
                    }
                }
  • 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-04T21:24:09+00:00Added an answer on June 4, 2026 at 9:24 pm

    Yes, just specify the name explicitly and alias it

    site_forum_threads.title AS title_from_site_forum_threads
    

    and access it using $latest['title_from_site_forum_threads']

    The select part in total could look like

    SELECT *, site_forum_threads.title AS title_from_site_forum_threads FROM ...
    

    but personally I recommend you to always select only necessary things, by enumerating all the fields separated by comma manually

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

Sidebar

Related Questions

I'm still beginner in PHP. I have a small problem, I would to multiply
I'm an beginner in php/msql, and need help to solve this problem: I have
I am a dead beginner with PHP and have been reading through 'PHP for
This is probably pretty basic, but I'm a beginner in PHP - I have
I'm a beginner and trying to get a handle on php. I have been
I am a beginner to ruby on rails.But i am quite comfortable with php,
I am a PHP beginner. I have developed a social networking website similar to
I am a PHP beginner and saw on the forum this PHP expression: My
I'm a little bit of a beginner to CakePHP and PHP in general, but
I know this is a beginner's question, but I've been searching online and all

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.