Jump to content

[SOLVED] Trouble outputting a variable?


galvin

Recommended Posts

I'm probably not explaining this will, so I'll apologize ahead of time.  Anway, I have a page that echos the following code (contained in $userRow) over and over for each User...

 


$userRow = "<tr><td class=\"name\">{$users["firstname"]}" . " " . "{$users["lastname"]}<br/><img src=\"http://gdoot.com/gsfl/images/user_{$users["userid"]}.jpg\" /> <span class=\"record\">RecordPlaceHolder</span><span></span></td>";

 

In that last empty span, I want it to display a certain number for each user.  Earlier in the code on the same page, I have a variable for each user to hold that number, such as..

 

$numberforuser_1 = 2

$numberforuser_2 = 4

$numberforuser_3 = 1

$numberforuser_4 = 4

$numberforuser_5 = 0

$numberforuser_6 = 2

 

And so on.

 

I have each user's ID (and first name and last name) stored in the $users array.  So in that last empty SPAN, I assumed I could put "<span>$numberforuser_{$users["userid"]}</span>" and I would think for each User it would output $numberforuser_X and therefore, if, for example, it was "$numberforuser5," it would output "0" in that SPAN since above, $numberforeuser_5 = 0.

 

But it's not doing that.  It seems like it won't let you call something first to get PART of a variable and then have that varible's value actually output.

 

I'm using the same thinking as you can see earlier that has "http://gdoot.com/gsfl/images/user_{$users["userid"]}.jpg" and that pulls in each user's ID fine and displays the proper image.  But since I'm putting a VARIABLE instead of a URL, it's not working.

 

Assuming that makes sense, which it probably doesn't, anyone know what I'm doing wrong, or another way to do this?

 

Link to comment
https://forums.phpfreaks.com/topic/136434-solved-trouble-outputting-a-variable/
Share on other sites

I'm a little lost, so this may get you lost... so possibly just ignore me.

$numberforuser[1] = 2

$numberforuser[2] = 4

$numberforuser[3] = 1

...

use $numberforuser[$users["userid"]]

 

but I really am lost on what you are looking for exactly

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.