Posts: 16
Threads: 2
Joined: Jul 2009
Reputation:
0
Hello, I've created a MySQL website for a RolePlay mode.
Everything is okay, I'm registering just fine... but one thing isn't okay.
I don't how to make a random phone number at the PHPMyAdmin... so, If player 1 has number "105050" and Player two jsut registerted, he should have number "105051", pretty much as LS:RP, please I need help!...
Thank you.
Posts: 6,129
Threads: 36
Joined: Jan 2009
The best thing to do is to generate it in pawn, as you can't create more than 1 auto incrementing field as far as I know.
Posts: 16
Threads: 2
Joined: Jul 2009
Reputation:
0
I know...
But, I have a MySQL server... and the details should be save, I need to know what to do.
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by Eliran Pesahov
I know...
But, I have a MySQL server... and the details should be save, I need to know what to do.
|
...So create a value, and save it in MySQL. /facepalm? Do I have to write the code out for you?... despite practically explaining in lamens terms.
Posts: 489
Threads: 102
Joined: Apr 2010
Reputation:
0
In PHP (or w/e) do it so its like..
You get the latest record in your database and get the phone number and +1 to it. then insert that into your db
Posts: 16
Threads: 2
Joined: Jul 2009
Reputation:
0
If I know how?...
That's why I opend that subject, so guys like would help me.
If you can tell me how to do it please? so, please... help.
Posts: 6,129
Threads: 36
Joined: Jan 2009
pawn Код:
new HighestNumber[ 12 ], HighestNumberInt;
mysql_query( "SELECT * FROM Users WHERE PhoneNumber = ( SELECT MAX( PhoneNumber ) FROM Users );" ); // Query for the result.
mysql_store_result(); // Store the result in memory
mysql_fetch_row_data(); // Fetch row data of the result
mysql_fetch_field( "PhoneNumber", HighestNumber ); // Fetch specific field
HighestNumberInt = strval( HighestNumber ); // This should be your highest number.
mysql_free_result(); // Free the result to avoid using excessive memory
I know it's not optimal, but I rushed it and the query could probably be executed better. Some functions may be different, depending on which plugin you use. I use StrickenKid's and I've used it for this example.