Load MYSQL and put in order
#1

I have a items system but when restart the server i need to set on order
For example if:
Код:
itemLIST 15 is itemID 11
itemLIST 16 is itemID 0
itemLIST 17 is itemID 0
itemLIST 18 is itemID 25
On load, i need to change to:
Код:
itemLIST 15 is itemID 11
itemLIST 16 is itemID 25 (from 18)
I've tried this OrderItems(), but after add it i can't load...
It printing:
Код:
[21:13:34] =================
[21:13:34] ordenar items
[21:13:34] =================
[21:13:34] itemloop [0] itemID [15]
[21:13:34] itemloop [0] itemID [16]
[21:13:34] itemloop [0] itemID [17]
[21:13:34] itemloop [0] itemID [18]
[21:13:34] itemloop [0] itemID [19]
[21:13:34] itemloop [0] itemID [20]
And if i remove OrderItems() load right, with no order ofc

PHP код:
LoadItems() {
    new 
listloop ServerStoreItems 1;
    while(
listloop MAX_LISTS) {
        new 
query[50]; // Nгo precisa ser enorme como vocк tinha colocado; Precisa apenas caber sua query dentro dela
        
mysql_format(ConnectMYSQLquerysizeof(query), "SELECT * FROM items WHERE itemLIST = '%d'"listloop);
        
mysql_tquery(ConnectMYSQLquery"Load_Items""i"listloop);
        
listloop++;
    }
    
OrderItems();
}
forward Load_Items(listloop); public Load_Items(listloop) {
    new 
rowsfields;
    
cache_get_row_count(rows);
    
cache_get_field_count(fields);
    if(
rows) {
        
// ints
        
cache_get_value_int(0"itemID"ItemInfo[listloop][itemID]);
    }
}
forward OrderItems(); public OrderItems() {
    
printf("=================");
    
printf("ordenar items");
    
printf("=================");
    new 
lastitem ServerStoreItems+1;
    for(new 
itemloop ServerStoreItems+1itemloop MAX_LISTSitemloop++) {
        
printf("itemloop [%i] itemID [%i]"ItemInfo[itemloop][itemID], itemloop);
        if(
ItemInfo[itemloop][itemID] > 0) {
            
lastitem++;
            
printf("lastitem [%i]"lastitem);
            
ItemInfo[lastitem][itemID] = ItemInfo[itemloop][itemID];
            new 
squery[2500];
            
mysql_format(ConnectMYSQLsquerysizeof(squery), "UPDATE `items` SET `itemID` = '%d'  WHERE itemLIST = '%d'",
                
ItemInfo[lastitem][itemID],
            
lastitem);
            
mysql_pquery(ConnectMYSQLsquery);
        }
    }

Reply
#2

Anybody know how to make it to order?
Reply
#3

Can't you just use "ORDER BY" in the query?
Reply
#4

I think this function don't solve my problem
I'll try to explain better:
I have a item system in my server.. it have to start 1 and finish on 100 but the item model can not be 0 when server start it need to be ordered

For example:
ID | MODEL
1 | 120
2 | 130
3 | 0
4 | 150

I need to make a order to when a model of a item be 0, the values of the next id, be moved like:
ID | MODEL
1 | 120
2 | 130
3 | 150
4 | 0
Reply
#5

bump, post edited
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)