PtokaX forum

Development Section => Your Developing Problems => Topic started by: GeceBekcisi on 15 August, 2005, 19:06:49

Title: Getting values from tables
Post by: GeceBekcisi on 15 August, 2005, 19:06:49
Which way should I follow to get values from table which has a structure like:tIPtable = {
[curUser.sIP] = {
[curUser.sName] = {
["Entered"] = "LogInDate",
["Left"] = "LogOutDate",
},
},
}
I need to search for curUser.sIP and if it is found, get curUser.sName, Entered and Left values.

And also, I need to search for curUser.sName and if it is found, get curUser.sIP, Entered and Left values.


Thanks for any help..
Title:
Post by: plop on 15 August, 2005, 19:21:00
example.
tIPtable = {
[curUser.sIP] = {
[curUser.sName] = {
["Entered"] = "LogInDate",
["Left"] = "LogOutDate",
},
},
}

if tIPtable[(curUser.sIP)] then
if tIPtable[(curUser.sIP)][(curUser.sName)] then
-- known username for the IP.
else
-- new username for the IP
end
else
-- build new table entry for IP
end

plop
Title:
Post by: bastya_elvtars on 15 August, 2005, 20:39:27
I think you should have entered and left in a different table, since these change more frequently than IP, and is easier to maintain.
Title:
Post by: GeceBekcisi on 15 August, 2005, 20:59:45
I only wanna get one entry & exit date per user in per ip. so that table is ok for now, I think