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

  • Home
  • SEARCH
  • 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 8452345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:28:34+00:00 2026-06-10T11:28:34+00:00

I have two tables. One which holds the user status content and the other

  • 0

I have two tables. One which holds the user status content and the other holding the users. How do I write the query of the users to obtain the user record for their given streamitem in streamdata? At current times, its only grabbing the user that is at the top of the user table.

$check = "SELECT streamitem_id, streamitem_timestamp, streamitem_content FROM streamdata WHERE streamitem_creator="$user1_id." AND streamitem_id=".$last." AND streamitem_type_id=1 ORDER BY streamitem_timestamp DESC";
$check1 = mysqli_query($mysqli,$check);
$resultArr = mysqli_fetch_array($check1);
$json['streamitem_id'] = $resultArr['streamitem_id'];
$json['streamitem_timestamp'] = Agotime($resultArr['streamitem_timestamp']);
$json['streamitem_content'] = $resultArr['streamitem_content'];
mysqli_free_result($check1);


$check = "SELECT * FROM users";
$check1 = mysqli_query($mysqli,$check);
$resultArr = mysqli_fetch_array($check1);
$json['username'] = $resultArr['username'];
$json['id'] = $resultArr['id'];
$json['first'] = $resultArr['first'];
$json['middle'] = $resultArr['middle'];
$json['last'] = $resultArr['last'];
mysqli_free_result($check1);


-- Table structure for table `streamdata`
--

    CREATE TABLE IF NOT EXISTS `streamdata` (
      `streamitem_id` int(11) NOT NULL auto_increment,
      `streamitem_type_id` int(11) NOT NULL,
      `streamitem_creator` int(11) NOT NULL,
      `streamitem_target` int(11) NOT NULL,
      `streamitem_timestamp` datetime NOT NULL,
      `streamitem_content` varchar(5000) NOT NULL,
      PRIMARY KEY  (`str

    eamitem_id`)
        ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1953 ;


    -- Table structure for table `users`
    --

    CREATE TABLE IF NOT EXISTS `users` (
      `id` int(11) NOT NULL auto_increment,
      `first` varchar(64) NOT NULL,
      `middle` varchar(64) NOT NULL,
      `last` varchar(64) NOT NULL,
     `username` varchar(64) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=150 ;
  • 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-10T11:28:35+00:00Added an answer on June 10, 2026 at 11:28 am

    Query to get user details and stream details for a given stream item:

    $check = "
    SELECT * FROM users u 
    INNER JOIN streamdata s ON
        (s.streamitem_creator = u.id AND s.streamitem_id = {$last})";
    

    Please note that it is bad practice to insert raw variable values into your queries. Especially if they come from user input. Look into mysqli_real_escape_string or try using prepared statements.

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

Sidebar

Related Questions

I have two tables. One user table and one table in which results are
I have two tables, one table is the items container, which holds all data
I have two tables, one of which matches ids to ratings and one of
I have two tables one called fs_note the other called dumy_fs_note I created after
i have two tables one is called addons and holds information about different addons,
I have two tables : one table it matchs and the other is teams.
I have a database that has two tables, one of which contains a foreign
I have two tables Notification and Acknowledgment. Acknowledgment has a field which holds the
I have two tables here: One holds a list of subscriber emails: (ID, email)
The database I am working with currently does have two tables, one holding the

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.