![]() |
how to get this to show for each user
hey guys, im having a bit of trouble with this, ill explain it a bit more in detail below:
basically, i have this piece of code, i want it to show whats after it to each user involved (in every case it will only be 2 people) PHP Code:
the idea is that if (($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 0)) it will show, but if (($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 1)) it wont, and exactly the same for the $fetch_escrow->username but im having problems having it show for one, and not for the other. any help would be great as i dont want to have to copy the script and write it twice if theirs and easier way around it. thanks. Dan |
if ((($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 0)) || (($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 0))) {
So this always has to be true: $fetch_escrow->invited == $fetch->username And this can be either a zero (0) or one (1): $fetch_escrow->invitedlevel == 0 $fetch_escrow->invitedlevel == 1 Is that the correct logic? Create a logic table for me so I can visualize it. EDIT: maybe this? if (($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 0 || $fetch_escrow->invitedlevel == 1)) { . |
sorry for not explaining it correctly. its a bit mind bogling to explain lol.
basically, if user=fetchescrow->username and username level == 0 dislay everything after the { but then in the same thing but for the invited user, and invited level == 0 then display. but if either has a 1 instead of a 0 do not display it to the person with the 1 does that make sense? |
Quote:
if ((($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 0)) || (($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 0))) { That is 3 variables isn't it? I'm guessing you have something called "usernamelevel" ?? . |
im sorry, i must have wrote it out incorrectly on here.. yes you are right, there is invitedlevel and userlevel both being drawn by the $fetch_escrow->
if ((($fetch_escrow->invited == $fetch->username) && ($fetch_escrow->invitedlevel == 0)) || (($fetch_escrow->username== $fetch->username) && ($fetch_escrow->usernamelevel == 0))) { so for each one it should display, only if its a 0, but if one changes to a 1 then it will not display for them, but will still display for the other user that has 0 |
Let's try expanding it out first, to make it easier to see what is happening ...
PHP Code:
Try that and see if it works. . |
that works for the invited user only, not the username user
|
Run it various ways and show me the results for it each time ...
PHP Code:
. |
Invited is: testaccount
Invited_level is: 0 Username is: DOS1392 Username_level is: 0 thats what i get. which is correct, now i want it to display "anything here" for each user "testacount" and "dos1392" as long as their own level is 0, but if theres is 1 and the other level for the other user is 0 still display to the other user, just not to the user with the 1 |
But look here: $fetch_escrow->invited == $fetch->username
You are requiring the invited name and username to be equal (the same). Nothing will ever happen if they are different. Let's look at your example: Invited is: testaccount Invited_level is: 0 Username is: DOS1392 Username_level is: 0 So this will always be false no matter if the level is 0,1,2, or 1000 The two items in red are NOT EQUAL. According to you, that is a requirement. . |
sorry, let me try to explain, this is an escrow system:
one user invites another user, the inviter is set as username in the escrow table, the invited is set as invited in the escrow table, $fetch->username is the session (user logged in) now each user needs to finalize their items in the escrow, to do this they are both set to 0 from the beginning. if username (inviter) clicks the finalize button, it updates "usernamelevel" to "1", but invited is still set to 0 so it should still show the finalize button. this is where im stuck, instead of re writing everything out for each user, i wanted to find a work around to display to either of the users as long as their user or invited level == "0" i hope that has explained it a bit more, if not im more than willing to provide a picture. |
Tell me if my theory of operation is at all close to what you're doing.
To start out, let's say there are already 147 other users logged-in. I sit down at my computer... I am 'mlseim' I log in and a SESSION is set for me (I'm logged-in). You are 'dan1307' You log in and a SESSION is set for you (You're logged-in). I want to invite you, so four variables are set: $fetch_escrow->username is now 'mlseim' $fetch_escrow->usernamelevel is now set to 0 $fetch_escrow->invited is now 'dan1307' $fetch_escrow->invitedlevel is now set to 0 You mentioned those are stored in a db (database?), like a temporary MySQL table? Do you (dan1307) and I (mlseim) see the same database variables in real time? How are you storing these in a db? How do you know that I invited you? And how do I know that you accepted my invitation? . |
your bang on :)
yes it is stored in a mysql database, that is temporary as long as the escrow is open. invites are sent out and the invited user must accept the invite. then comes the other part ive already coded that works fine, placing items such as cars, money ect ect into the escrow system, that works fine and is all coded. then once each user has put in what they want, they each INDIVIDUALLY press the finalize button (this is the part im having trouble with) as i want that button to show up for each user if they are set to 0, but if they are set to 1 i dont want it to show. my problem is, how can i make it show for one user, and not the other, whilst only writting that finalize button out once, instead of twice for each person? but going back to how you worked it out, you was bang on, right down to the T |
As long as I am logged-in and I invited you, there must be a SESSION variable someplace that my PHP script knows which database table to query.
You are logged-in on your computer, and you also have a SESSION variable that tells your PHP script which database table to query. We are both querying the same temporary table, isn't that correct? We are both running (or using) the same PHP script, and we both have a SESSION variable that tell us which temporary table to use. Whenever either of us queries that db table, the PHP script has to determine whether we are the "inviter" or the "invitee". You set a SESSION to know what the table name is, but no other information. So, I would guess you do this ... Whenever the page displays, the PHP does these steps: 1) It already knows my login SESSION. 2) It queries the database for those 4 things. 3) It determines if I'm the "inviter" or the "invitee". 4) If I'm the "inviter", it looks to see if my "level" is 0 (for userlevel). 5) If so, it shows the button. 6) If I'm the "invitee", it looks to see if my "level" is 0 (for invited_level). 7) If so, it shows the button. 8) If I had clicked my finalize button, it would update the appropriate column for me. 9) It goes back to step 1. So you have to do 2 "if" statements (step 4-5) and (step 6-7) PHP Code:
. |
this part is bang on:
PHP Code:
|
| All times are GMT +1. The time now is 01:50 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.