MySQL loading data with loops?
#1

Is there any way to load the columns in Mysql database with a loop?

I have the following columns in the database:
Код:
Object1, Object2, Object3, Object4, Object5
I tried something like that, but I think it's got to be formatted, I do not know how.
Код:
	if(cache_num_rows() > 0)
	{
		for(new i=0; t < 5; i++)	
		{  
			cache_get_value_int(0, 		"Object%d", 		Player[playerid][Object][%d]);	

		}
	}
Reply
#2

Yes.

Swap that
pawn Код:
t < 5; i++
for
pawn Код:
t < cache_num_rows(); i++)
. Then the row number (first parameter) becomes i, instead of 0, 1, 2, 3 etc.

This is how i used to load a few hundred vehicles anyway, possibly someone has a better way of doing it.

pawn Код:
if(cache_num_rows() > 0)
    {
        for(new i=0; t < cache_num_rows(); i++)
        {  
            cache_get_value_int(i,      "Object%d",         Player[playerid][Object][%d])

        }
    }
Reply
#3

She does not want to work, I did that
Код:
	if(cache_num_rows() > 0)
	{
		for(new i=1; i <cache_num_rows (); i++)	
		{  
			cache_get_value_int(i, 		"S%d", 				pInventory[playerid][invSlot][i]);	
		}

	}
Reply
#4

I want to load a loop all the objects: Object1 Object2, etc.
But I do not find a modali ...
That's what the database looks like

Reply
#5

Code seems to be fine. I have a similar code in my testing mode too.

So what exactly is the problem? Data isn't fetched properly? If so, look for any warnings/errors in 'mysql/warnings' in your server directory.

If objects are not being created? How could they even create? You didn't use Create(Dynamic)Object function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)