The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
cross linking two arrays ?
Can someone help ?
I'm trying to write good code, keeping queries to a minimum etc. What I want to do is take a query which returns an array, then you do a while loop to cycle through the array. Is there anyway to crossreferece this with another array without putting it into the loop ? Lets post an example, it will probably help, lol If you take the karma hack, usercp bit. PHP Code:
PHP Code:
PHP Code:
$karmas[whoadded] who return the array $karma[whoadded] who return the id's one by one in the while loop What if I wanted to return the username of the user. I would have to do something like PHP Code:
$karma[whoadded] = userid $karma[username] = username I hope I have explained this, can anyone help please ? Am I right I can do this using 2 queries ? |
#2
|
||||
|
||||
Sorry to bump this thread, but do I take it that its not possible
Or I have not described what I need very well ? Can anyone comment even if its not the total solution ? Thanks |
#3
|
||||
|
||||
I think I understand what you want, take a look at this:
PHP Code:
|
#4
|
||||
|
||||
Actually, looking back and re-reading this ... I dont think you need to do this whole "whoadded" thing at all.
Use the same code I posted above but remove the whoadded from the first line. Now use these: $karma[userid] $karma[username] * Note: Its karma, not karma(s) |
#5
|
||||
|
||||
Nomb, thanks for the reply.
Looking at your post, is this correct ? When it queries the user table, I was after the username WHERE userid = $whoadded that would return the usernames of the people who gave me karma ? But am I able to do the query in this way as it wont know what whoadded is until its run ? Any ideas ? |
#6
|
||||
|
||||
just seen your reply, I dont want my username, as in User=$bbuserinfo[username]. I want the usernames of the users that gave me karma.
their id's are collected in the whoadded column Can you suggest what i do ? Thanks for all your help so far |
#7
|
||||
|
||||
O, ok, I didn't know what the hell this hack was lol.
Um ... you're gonna need two queries then because you have two different WHERE conditions. Pretty sure. |
#8
|
||||
|
||||
yep, but do you know how I need to do it ?
If I do the first query I'll get the karma details and the userid of the person who donated the karma. Then I need to do another query to get the usernames for the user id's But how do I then combine them ? Before I put them into the mysql_fetch_array ? |
#9
|
||||
|
||||
How are userid's stored in the whoadded row?
Like this: 6,4,9,18 ? |
#10
|
||||
|
||||
it will only be one number in each individual row.
I would guess so anyway. only one person can add karma to every karma id |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|