Load string from mysql
#1

Hey all,

Today I tried to load a string (number plate) from mysql but it load only the first case...

Код:
strmid(CarInfos[i][Plaque], fields[15], 0, strlen(fields[15]), 255);
What do I need to do ?

Thanks
Reply
#2

Here is a exaple
PHP код:
stock LoadCars(maxid)
{
    for(new 
i=0i<=maxidi++)
    {
        new 
podatak[80];
        
format(podatak,sizeof(podatak),"SELECT * FROM `cars` WHERE `ID` = '%d'",i);
        
mysql_query(podatak);
        
mysql_store_result();
        while(
mysql_retrieve_row())
        {
            
mysql_fetch_field_row(podatak,"Owner"); strmid(Car[i][Owner], podatak0strlen(podatak), 50);
            
mysql_fetch_field_row(podatak,"Model"); Car[i][Model] = strval(podatak);
            
mysql_fetch_field_row(podatak,"X"); Car[i][X] = floatstr(podatak);
            
mysql_fetch_field_row(podatak,"Y"); Car[i][Y] = floatstr(podatak);
            
mysql_fetch_field_row(podatak,"Z"); Car[i][Z] = floatstr(podatak);
            
mysql_fetch_field_row(podatak,"Rot"); Car[i][Rot] = floatstr(podatak);
            
mysql_fetch_field_row(podatak,"Color1"); Car[i][Color1] = strval(podatak);
            
mysql_fetch_field_row(podatak,"Color2"); Car[i][Color2] = strval(podatak);
            
mysql_fetch_field_row(podatak,"Locked"); Car[i][Locked] = strval(podatak);
            
mysql_fetch_field_row(podatak,"Plate"); strmid(Car[i][Plate], podatak0strlen(podatak), 10);
            
mysql_fetch_field_row(podatak,"Owned"); Car[i][Owned] = strval(podatak);
            
mysql_fetch_field_row(podatak,"Cost"); Car[i][Cost] = strval(podatak);
            
format(podatak,sizeof(podatak),"Car %d loaded MODEL:%d x:%f y:%f Z:%f",iCar[i][Model], Car[i][X],  Car[i][Y],  Car[i][Z]);
            print(
podatak);
        }
    }
    return 
1;

Example how to use (i use it on gamemodeinit)

PHP код:
    mysql_query("SELECT MAX(ID) FROM `cars`"); mysql_store_result(); new caridmysql_fetch_int(); mysql_free_result();
    if(
carid== -1) print("There is no cars to load");
    else 
LoadCars(carid); 
Sorry for bad english!
Reply
#3

Hmm, gonna try this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)