Help with defining a new variable

I’d like to define a variable that is the wallet amount of the ‘seller’.

‘wallet’ is column in the ‘users’ table with a numeric amount in it.
Users have unique id numbers in the ‘id’ column of the ‘users’ table.

Can you tell me if this is a valid variable line:

$sellerwallet = $user_id->wallet;

If this helps you, in the php file that I’d like to modify, I see these lines:

$user_id = $user->id;


‘user_id’ => $video->user_id, //seller

If my $sellerwallet line is incorrect, can you give me an idea or example of what my defined variable line might appropriately look like? Thanks
I look forward to your comments/guidance

1 Like

There isn’t enough context here to know if any of it is correct.
It looks like there is OOP involved, but without knowing the nature of the classes involved, it’s hard to know anything.

I agree with SamA74 and you have the code in front of you. You can try things and test them better than us making guesses… , In my mind $user_id would be the user id and $user would probably be an array of information about the user… Also logically if $user->id; returns the value of the user id field and wallet is also a field in the same table, I would think you can call for wallet in the same way using $user->wallet; . How would you test to see if this returns the expected result? You could set a variable and echo it.

$sellerwallet = $user->wallet;
echo $sellerwallet;
1 Like

The $user_id variable is already defined as the id number of the user. You would just need to call the wallet column from the users table. It would look like this:

$sellerwallet = $users->wallet;

Where has $users come from?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.