Here is a exaple
PHP код:
stock LoadCars(maxid)
{
for(new i=0; i<=maxid; i++)
{
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], podatak, 0, strlen(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], podatak, 0, strlen(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",i, Car[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 carid= mysql_fetch_int(); mysql_free_result();
if(carid== -1) print("There is no cars to load");
else LoadCars(carid);
Sorry for bad english!