MySQL loop issue.
#1

Good morning.

I have a function to check whether the id in my database is used or not.

However it is not as super method.

A loop would be better?

Voici le code actuel:

Here is the current code:

pawn Код:
stock IDExistantWeed()
{
    new str[50], weedID = 1;
    format(str, sizeof(str), "SELECT * FROM srp_players_weed WHERE id=%d LIMIT 1", weedID);
    mysql_query(str);
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
       
    }
    else printf("Pas de weed ID SQL: %i", weedID);
    mysql_free_result();
    return 1;
}
And i use:

pawn Код:
idzeub = IDExistantWeed();
WeedInfo[idzeub][ID] = idzeub;
...
Thanks
Reply
#2

Loop is not the best way to check the ID. It's the worst if you ask me.
If you set ID field as AUTO_INCREMENT then rather than doing loop you can SELECT *.
and then use:
while(db_num_rows) {
mysql_fetch_row(data);
and use sscanf to seperate details.
}
( while loop )
and then mysql_free_result();
with this you can set every ID in your DB to true in script.
Reply
#3

Help me? I don't work
Reply
#4

up ..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)