26.10.2016, 20:02
Here is table structure representation:
So to count all items owned by a user:
Code:
If you have a max item limit, say #define MAX_ITEMS (10), the for loop will be:
You can use Username instead of UID in case you want string matching. But i recommend UID.
PHP код:
Items
ID - INTEGER - PRIMARY_KEY
Type - INTEGER
UID - INTEGER - FOREIGN KEY
Users
ID - INTEGER - PRIMARY_KEY
...
PHP код:
SELECT `Type` FROM `Items` WHERE `UID` = <user_id>
PHP код:
OnLoad()
{
for (new i, j = cache_get_rows_count(); i < j; i++)
{
// do stuff
}
}
PHP код:
OnLoad()
{
new limit = cache_get_rows_count();
if (limit > MAX_ITEMS)
limit = MAX_ITEMS;
for (new i; i < limit ; i++)
{
// do stuff
}
}