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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:43:38+00:00 2026-05-16T22:43:38+00:00

I have this object: foreach(range(1,$oc->num_users) as $num) { $user = ‘user’ . $num; $$user

  • 0

I have this object:

foreach(range(1,$oc->num_users) as $num) {
    $user = 'user' . $num;
    $$user = mysql_fetch_object(mysql_query("SELECT user".$num.", user".$num."_ready,  FROM oc_db WHERE leader='".$_SESSION['username']."' ")); 

This gives objects named user1..X

later I have a simular function like this, where I use the $$user->$user that represent a username to connect to the db to get additional information.

   $$user = mysql_fetch_object(mysql_query("SELECT x, y, z FROM user_db WHERE username='".$$user->$user."' "));

This also makes objects named user1..X, but instead of replacing the object created earlier I want to append this values to the object I created in the first function. $$user is the name of the objects. I would like to do something like $$user .= fetch_object in the last function, but off course it’s not that simple.

  • 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-16T22:43:38+00:00Added an answer on May 16, 2026 at 10:43 pm

    In order to append one object to another you simply need to iterate through the first object and then assign each property you find to the second one:

    $tmp = mysql_fetch_object(mysql_query("SELECT x, y, z FROM user_db WHERE username='".$$user->$user."' "));
    
    foreach ($tmp as $key => $value) {
        $$user->$key = $value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can store an instance object foreach user session? I have a class
i have this model on mvc: public class User { public string Name {
I have: Foo foo = new Foo(); foreach (i; 0..10) { Bar bar =
I have this weird code on site. It gets all records (order by pozycja),
I have this URL where there is XML data. I have to extract that
So I have this class public static class MyClass { static MyClass() { ...
Here's what I am trying to accomplish - I have about a million files
I have a problem while trying to batch convert the encoding of some files
I have got a collection of viewModels(InputViewModel) in an other viewModel(ScenarioManager). each InputviewModel has

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.