Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2010
    Messaggi
    110

    Modifica campo in tutti ID

    Ciao ho una tabella del mio database chiamata utenti e con vari campi tra cui quelli risorse, legno, marmo, olio.
    Adesso con uno script php vorrei aumentare di 1000 quei campo per tutti gli ID cioè:
    1 id risorse 100, olio 100, marmo 100, legno 100 dopo lo script diventerà: risorse 1100 ecc
    stessa cosa per gli altri ID ognuno equivalente ad un utente

  2. #2
    Se ho capito...

    codice:
    update utenti
    set 
    campo1 = campo1 + 1000,
    campo2 = campo2 + 1000,
    campo3 = campo3 + 1000,
    campo4 = campo4 + 1000,
    campo5 = campo5 + 1000;

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2010
    Messaggi
    110
    Penso di no cioè io ho
    ID: 1 nick: bho risorse: 2
    Id: 2 ncik: ciao risorse: 3
    ecc
    E vorrei aggiungere a tutti gli id nel campo risorse 1000 quindi così:
    ID: 1 nick: bho risorse: 2 più 1000
    ID: 2 nick: ciao risorse: 3 più 1000

  4. #4
    mi pare sia quello che ti ho proposto.

    semplifico:

    codice:
    update utenti
    set 
    risorse = risorse + 1000;

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  5. #5
    Utente di HTML.it
    Registrato dal
    Aug 2010
    Messaggi
    110
    Quindi faccio la connessione al db e copio quei codici??
    e sostituisco risorse con la tabella da aumentare??

  6. #6
    Originariamente inviato da idro
    Quindi faccio la connessione al db e copio quei codici??
    e sostituisco risorse con la tabella da aumentare??
    Eh no...

    questa e' la classica domanda che non chiarisce le idee non chiare. Quale tabella da aumentare? quale connessione? con cosa? come e' fatta l'attuale tabella?

    cosa significa "vari campi tra cui quelli risorse, legno, marmo, olio" ???

    hai un campo con tante voci diverse oppure hai un campo risorse, un campo legno,uno marmo e l'altro olio?

    Non e' la stessa cosa.

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  7. #7
    Utente di HTML.it
    Registrato dal
    Aug 2010
    Messaggi
    110
    Allora ho un tabella uni1_planets:
    ecco la struttura:
    Codice PHP:
    CREATE TABLE IF NOT EXISTS `uni1_planets` (
      `
    idint(11unsigned NOT NULL AUTO_INCREMENT,
      `
    namevarchar(255) DEFAULT 'Hauptplanet',
      `
    id_ownerint(11unsigned DEFAULT NULL,
      `
    id_leveltinyint(1unsigned DEFAULT '0',
      `
    universetinyint(3unsigned NOT NULL,
      `
    galaxytinyint(3NOT NULL DEFAULT '0',
      `
    systemsmallint(5NOT NULL DEFAULT '0',
      `
    planettinyint(3NOT NULL DEFAULT '0',
      `
    last_updateint(11) DEFAULT NULL,
      `
    planet_typeenum('1','3'NOT NULL DEFAULT '1',
      `
    destruyedint(11NOT NULL DEFAULT '0',
      `
    b_buildingint(11NOT NULL DEFAULT '0',
      `
    b_building_idvarchar(500NOT NULL DEFAULT '',
      `
    b_hangarint(11NOT NULL DEFAULT '0',
      `
    b_hangar_idvarchar(500NOT NULL DEFAULT '',
      `
    b_hangar_plusint(11NOT NULL DEFAULT '0',
      `
    imagevarchar(32NOT NULL DEFAULT 'normaltempplanet01',
      `
    diameterint(11unsigned NOT NULL DEFAULT '12800',
      `
    field_currentsmallint(5unsigned NOT NULL DEFAULT '0',
      `
    field_maxsmallint(5unsigned NOT NULL DEFAULT '163',
      `
    temp_minint(3NOT NULL DEFAULT '-17',
      `
    temp_maxint(3NOT NULL DEFAULT '23',
      `
    metaldouble(50,0unsigned NOT NULL DEFAULT '0',
      `
    metal_perhourdecimal(10,0unsigned NOT NULL DEFAULT '0',
      `
    metal_maxbigint(20unsigned DEFAULT '100000',
      `
    crystaldouble(50,0unsigned NOT NULL DEFAULT '0',
      `
    crystal_perhourdecimal(10,0unsigned NOT NULL DEFAULT '0',
      `
    crystal_maxbigint(20unsigned DEFAULT '100000',
      `
    deuteriumdouble(50,0unsigned NOT NULL DEFAULT '0',
      `
    deuterium_usedint(11unsigned NOT NULL DEFAULT '0',
      `
    deuterium_perhourdecimal(10,0unsigned NOT NULL DEFAULT '0',
      `
    deuterium_maxbigint(20unsigned DEFAULT '100000',
      `
    energy_usedbigint(11unsigned NOT NULL DEFAULT '0',
      `
    energy_maxbigint(20unsigned NOT NULL DEFAULT '0',
      `
    metal_minetinyint(3unsigned NOT NULL DEFAULT '0',
      `
    crystal_minetinyint(3unsigned NOT NULL DEFAULT '0',
      `
    deuterium_sintetizertinyint(3unsigned NOT NULL DEFAULT '0',
      `
    solar_planttinyint(3unsigned NOT NULL DEFAULT '0',
      `
    fusion_planttinyint(3unsigned NOT NULL DEFAULT '0',
      `
    robot_factorytinyint(3unsigned NOT NULL DEFAULT '0',
      `
    nano_factorytinyint(3unsigned NOT NULL DEFAULT '0',
      `
    hangartinyint(3unsigned NOT NULL DEFAULT '0',
      `
    metal_storetinyint(3unsigned NOT NULL DEFAULT '0',
      `
    crystal_storetinyint(3unsigned NOT NULL DEFAULT '0',
      `
    deuterium_storetinyint(3unsigned NOT NULL DEFAULT '0',
      `
    laboratorytinyint(3unsigned NOT NULL DEFAULT '0',
      `
    terraformertinyint(3unsigned NOT NULL DEFAULT '0',
      `
    universitytinyint(3unsigned NOT NULL DEFAULT '0',
      `
    ally_deposittinyint(3unsigned NOT NULL DEFAULT '0',
      `
    silotinyint(3unsigned NOT NULL DEFAULT '0',
      `
    mondbasistinyint(3unsigned NOT NULL DEFAULT '0',
      `
    phalanxtinyint(3unsigned NOT NULL DEFAULT '0',
      `
    sprungtortinyint(3unsigned NOT NULL DEFAULT '0',
      `
    small_ship_cargobigint(20unsigned NOT NULL DEFAULT '0',
      `
    big_ship_cargobigint(20unsigned NOT NULL DEFAULT '0',
      `
    light_hunterbigint(20unsigned NOT NULL DEFAULT '0',
      `
    heavy_hunterbigint(20unsigned NOT NULL DEFAULT '0',
      `
    crusherbigint(20unsigned NOT NULL DEFAULT '0',
      `
    battle_shipbigint(20unsigned NOT NULL DEFAULT '0',
      `
    colonizerbigint(20unsigned NOT NULL DEFAULT '0',
      `
    recyclerbigint(20unsigned NOT NULL DEFAULT '0',
      `
    spy_sondebigint(20unsigned NOT NULL DEFAULT '0',
      `
    bomber_shipbigint(20unsigned NOT NULL DEFAULT '0',
      `
    solar_satelitbigint(20unsigned NOT NULL DEFAULT '0',
      `
    destructorbigint(20unsigned NOT NULL DEFAULT '0',
      `
    dearth_starbigint(20unsigned NOT NULL DEFAULT '0',
      `
    battleshipbigint(20unsigned NOT NULL DEFAULT '0',
      `
    lune_noirbigint(20unsigned NOT NULL DEFAULT '0',
      `
    ev_transporterbigint(20unsigned NOT NULL DEFAULT '0',
      `
    star_crasherbigint(20unsigned NOT NULL DEFAULT '0',
      `
    giga_recyklerbigint(20unsigned NOT NULL DEFAULT '0',
      `
    dm_shipbigint(20NOT NULL DEFAULT '0',
      `
    orbital_stationbigint(20unsigned NOT NULL DEFAULT '0',
      `
    misil_launcherbigint(20unsigned NOT NULL DEFAULT '0',
      `
    small_laserbigint(20unsigned NOT NULL DEFAULT '0',
      `
    big_laserbigint(20unsigned NOT NULL DEFAULT '0',
      `
    gauss_canyonbigint(20unsigned NOT NULL DEFAULT '0',
      `
    ionic_canyonbigint(20unsigned NOT NULL DEFAULT '0',
      `
    buster_canyonbigint(20unsigned NOT NULL DEFAULT '0',
      `
    small_protection_shieldtinyint(1unsigned NOT NULL DEFAULT '0',
      `
    planet_protectortinyint(1unsigned NOT NULL DEFAULT '0',
      `
    big_protection_shieldtinyint(1unsigned NOT NULL DEFAULT '0',
      `
    graviton_canyonbigint(20unsigned NOT NULL DEFAULT '0',
      `
    interceptor_misilint(11unsigned NOT NULL DEFAULT '0',
      `
    interplanetary_misilint(11unsigned NOT NULL DEFAULT '0',
      `
    metal_mine_porcentenum('0','1','2','3','4','5','6','7','8','9','10'NOT NULL DEFAULT '10',
      `
    crystal_mine_porcentenum('0','1','2','3','4','5','6','7','8','9','10'NOT NULL DEFAULT '10',
      `
    deuterium_sintetizer_porcentenum('0','1','2','3','4','5','6','7','8','9','10'NOT NULL DEFAULT '10',
      `
    solar_plant_porcentenum('0','1','2','3','4','5','6','7','8','9','10'NOT NULL DEFAULT '10',
      `
    fusion_plant_porcentenum('0','1','2','3','4','5','6','7','8','9','10'NOT NULL DEFAULT '10',
      `
    solar_satelit_porcentenum('0','1','2','3','4','5','6','7','8','9','10'NOT NULL DEFAULT '10',
      `
    last_jump_timeint(11NOT NULL DEFAULT '0',
      `
    der_metaldouble(50,0unsigned NOT NULL DEFAULT '0',
      `
    der_crystaldouble(50,0unsigned NOT NULL DEFAULT '0',
      `
    id_lunaint(11NOT NULL DEFAULT '0',
      
    PRIMARY KEY (`id`),
      
    KEY `id_luna` (`id_luna`),
      
    KEY `galaxy` (`galaxy`,`system`,`planet`,`planet_type`),
      
    KEY `id_owner` (`id_owner`),
      
    KEY `destruyed` (`destruyed`), 
    Devi aggiungere 1000 ai campi metal, crystall e deuterium

  8. #8
    non capisco perche' double(50,0) mi pare senza troppo senso.

    comunque fai il solito update:

    codice:
    update `uni1_planets`
    set metal = metal + 1000, 
    crystall = crystall + 1000,
    deuterium = deuterium + 1000;
    se nei campi citati avevi per esempio 50 diventeranno 1050.

    Fai una copia della tabella e prova a verificare che il risultato sia quello atteso.

    Se e' questo che vuoi fallo pure .... ma perche' double(50,0) ????

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  9. #9
    Utente di HTML.it
    Registrato dal
    Aug 2010
    Messaggi
    110
    non lo so è xnova

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.