MySQL LoadHouse
#1

Removed
Reply
#2

First of all you'd need to create the table and are you sure your script is even running MySQL?
Reply
#3

Removed
Reply
#4

100% untested but if you know the basis on MySQL this should be easy for you.

PHP код:
stock LoadHouses()
{
    new 
rowsidx 1string[256], query[256], query2[200], lines;
    
format(querysizeof(query), "SELECT * FROM houses");
    
mysql_query(query);
    
mysql_store_result();
    
lines mysql_num_rows();
    
mysql_free_result();
    for(new 
1linesi++)
    {
        
format(query2sizeof(query2), "SELECT * FROM houses WHERE id = %i"i);
        
mysql_query(query2);
        
mysql_store_result();
        while(
mysql_fetch_row_format(query2"|"))
        {
            
mysql_fetch_field_row(HouseInfo[i][hPrice], "houseprice");
             
mysql_fetch_field_row(HouseInfo[i][hStatus], "housestatus");
             
mysql_fetch_field_row(HouseInfo[i][hOwner], "houseowner");
             
mysql_fetch_field_row(HouseInfo[i][hX], "housex");
             
mysql_fetch_field_row(HouseInfo[i][hY], "housey");
             
mysql_fetch_field_row(HouseInfo[i][hZ], "housez");
             
             
HouseInfo[i][hPickup] = CreateDynamicPickup(12731HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ], 0);
              if(!
strcmp("trapstar2020"HouseInfo[i][hOwner]))
              {
                 
format(stringsizeof(string), "ID: %d\nOwner: %s\nStatus: For Sale\nPrice: $%d"iHouseInfo[i][hOwner], HouseInfo[i][hPrice]);
            }
             else 
format(stringsizeof(string), "ID: %d\nOwner: %s\nStatus: %s"i,  HouseInfo[i][hOwner], hlock(i));
             {
                
HouseInfo[i][hText] = CreateDynamic3DTextLabel(stringCOLOR_PURPLEHouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]+0.315);
               }
            
idx++;
            
mysql_free_result();
           }
           
printf("[Script] %d Houses were loaded."idx);
    }
    return 
1;

Reply
#5

Removed
Reply
#6

Quote:
Originally Posted by Peach
Посмотреть сообщение
100% untested but if you know the basis on MySQL this should be easy for you.

PHP код:
stock LoadHouses()
{
    new 
rowsidx 1string[256], query[256], query2[200], lines;
    
format(querysizeof(query), "SELECT * FROM houses");
    
mysql_query(query);
    
mysql_store_result();
    
lines mysql_num_rows();
    
mysql_free_result();
    for(new 
1linesi++)
    {
        
format(query2sizeof(query2), "SELECT * FROM houses WHERE id = %i"i);
        
mysql_query(query2);
        
mysql_store_result();
        while(
mysql_fetch_row_format(query2"|"))
        {
            
mysql_fetch_field_row(HouseInfo[i][hPrice], "houseprice");
             
mysql_fetch_field_row(HouseInfo[i][hStatus], "housestatus");
             
mysql_fetch_field_row(HouseInfo[i][hOwner], "houseowner");
             
mysql_fetch_field_row(HouseInfo[i][hX], "housex");
             
mysql_fetch_field_row(HouseInfo[i][hY], "housey");
             
mysql_fetch_field_row(HouseInfo[i][hZ], "housez");
             
             
HouseInfo[i][hPickup] = CreateDynamicPickup(12731HouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ], 0);
              if(!
strcmp("trapstar2020"HouseInfo[i][hOwner]))
              {
                 
format(stringsizeof(string), "ID: %d\nOwner: %s\nStatus: For Sale\nPrice: $%d"iHouseInfo[i][hOwner], HouseInfo[i][hPrice]);
            }
             else 
format(stringsizeof(string), "ID: %d\nOwner: %s\nStatus: %s"i,  HouseInfo[i][hOwner], hlock(i));
             {
                
HouseInfo[i][hText] = CreateDynamic3DTextLabel(stringCOLOR_PURPLEHouseInfo[i][hX], HouseInfo[i][hY], HouseInfo[i][hZ]+0.315);
               }
            
idx++;
            
mysql_free_result();
           }
           
printf("[Script] %d Houses were loaded."idx);
    }
    return 
1;

That's not the right way to fetch a result set from a MySQL table. You first select all of the records, and then run a query to fetch each record? It is more practical to fetch all of the records and then loop through them, storing the data into server memory.
Reply
#7

Ah I see what you mean. I see what I did wrong, thanks for pointing that out. I load my houses differently to this so it was harder for me to do it this way.
Reply
#8

Removed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)