Mobile system
#5

Well, I just gave you an example of how to do it. It depends on if you are using it as a table or field.
pawn Код:
// An example of how I used it
    // Deleting..
    format( Query, sizeof( Query ), "DROP TABLE `CONTACT%d`", contact_id ); // It is supposed by a command or dialog (read it from there)
    db_free_result( db_query( Database, Query ) );
   
    for( new x = 0; x < Loaded_Contacts; x++ )
    {
        if( Loaded_Contacts == 1 ) break;
        if( Loaded_Contacts == Is_Last_Contact ) break; // Is_Last_Contact = number of rows from a db_query or what MySQL uses
        // Renaming `CONTACTS`
        format( Query, sizeof( Query ), "SELECT * FROM `MOBILES` WHERE `CONTACT` = '%d'", x );
        Result = db_query( Database, Query );
        if( db_num_rows( Result ) )
        {
            print( "Results were found for loading contacts from database! Skipping.." );
            continue;
        }
        else
        {
            print( "No results were found from database! Updating.." );
            format( Query, sizeof( Query ), "UPDATE `MOBILES` SET CONTACT = '%d' WHERE `CONTACT` = '%d'", x, x + 1 );
            db_free_result( db_query( Database, Query ) );
            format( Query, sizeof( Query ), "ALTER TABLE `CONTACT%d` RENAME TO `CONTACT%d`", x + 1, x );
            db_free_result( db_query( Database, Query ) );
        }
    }
Reply


Messages In This Thread
Mobile system - by Larry123 - 10.11.2012, 15:35
Re: Mobile system - by Virus. - 10.11.2012, 15:53
Re: Mobile system - by Konstantinos - 10.11.2012, 15:57
Re: Mobile system - by Larry123 - 10.11.2012, 16:04
Re: Mobile system - by Konstantinos - 10.11.2012, 16:16
Re: Mobile system - by Larry123 - 10.11.2012, 16:29
Re: Mobile system - by Konstantinos - 10.11.2012, 16:39
Re: Mobile system - by Larry123 - 10.11.2012, 16:44
Re: Mobile system - by Larry123 - 10.11.2012, 17:06
AW: Mobile system - by Nero_3D - 10.11.2012, 18:09

Forum Jump:


Users browsing this thread: 1 Guest(s)