MySQL help
#1

I've got this function:
pawn Код:
stock GivePlayerPhone(playerid)
{
    new Cache:result = mysql_query(g_SQL, "SELECT COUNT(*) FROM `players`");
    new players;
    cache_get_value_int(0, 0, players);
    if(players == 1)
    {
        Player[playerid][Phone] = 42455;
        cache_delete(result);
    }
    else
    {
        new Cache:lastPhone =  mysql_query(g_SQL, "SELECT 'phone' FROM `players` ORDER BY  MAX(id) DESC LIMIT 1)");
        new phone;
        cache_get_value_int(0, 0, phone);
        Player[playerid][Phone] = phone + 1;
        cache_delete(lastPhone);
    }
}
Basically what it does is it gives a player a phone number, the first player to buy a phone gets the number 42455, and from there it should increase (42456, 42457, etc..). I got the first phone number working, but the second part of the code isn't working, in the database it just saves the row ID in the phone field instead of the increasing phone number. So what would be the correct query to use for this kind of thing?

P.S. if there is a simpler or more efficient way to do this please tell me, I suck with mysql stuff

Thanks in advance.
Reply


Messages In This Thread
MySQL help - by Onfroi - 05.01.2017, 23:09
Re: MySQL help - by Vince - 05.01.2017, 23:52
Re: MySQL help - by Onfroi - 06.01.2017, 00:17
Re: MySQL help - by Spmn - 06.01.2017, 00:45
Re: MySQL help - by Onfroi - 06.01.2017, 00:56

Forum Jump:


Users browsing this thread: 2 Guest(s)