Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. Fusione vari query come procedere?

Fusione vari query come procedere?

Pianificato Fissato Bloccato Spostato Coding
5 Post 2 Autori 476 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • G
    G
    guadagnaeuro
    Bannato
    scritto su ultima modifica di
    Super User 290
    #1
    Fusione vari query come procedere?

    Ciao a tutti

    utilizzo varie query per la pulizia degli archivi mysql di un sito, praticamente mi appare un bottoncino, clicco e cancella delle informazioni nel mysql per allegerirlo e funque farne una pulizia (utenti inattivi, messagi vecchi etc..)

    adesso vorrei sapere se è possibile fondere tutte queste quesry in 1 sola query in modo da cliccare 1 bottoncino e avviare tutte le pulizie uniche e non dovrei avviare ogni volta tante query.

    Qua inserisco il contenuto di ogni query (sono tutte molto simili e semplici) le vorrei solo fondere in 1 unico files cleanall.php

    Spero che mi possiamo aiutare, grazie mille

    query singole (funzionano singolamente)

    <b>Clean Ads</b>
    <br><br>

    <?
    if ($_POST){

    $tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
    while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen

    $igual=$registro5["plan"];

    //Todo parece correcto procedemos con la inserccion
    $queryz9 = "DELETE FROM tb_ads WHERE tipo='ads' AND members='$igual'";
    mysql_query($queryz9) or die(mysql_error());
    }

    echo "<b>Done.</b><br><br>";

    }
    ?>
    This Button Will Clean Old Ads.
    <br><br>
    <form method="post" action="index.php?op=13">
    <input type="hidden" name="clean" value="clean">
    <input type="submit" Value="Clean" class="button">
    </form>

    </table>


    <b>Clean Break Frame Ads</b>
    <br><br>

    <?
    if ($_POST){

    $tabla5 = mysql_query("SELECT * FROM tb_ads where tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
    while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen

    $queryz9 = "DELETE FROM tb_ads WHERE
    url LIKE '%ucash.in%' OR
    url LIKE '%urlcash.net%' OR
    url LIKE '%eightteen.com%' OR
    url LIKE '%pornyhost.com%' OR
    url LIKE '%urlcash.org%' OR
    url LIKE '%clb1.com%' OR
    url LIKE '%urlgalleries.com%' OR
    url LIKE '%celebclk.com%' OR
    url LIKE '%looble.net%' OR
    url LIKE '%smilinglinks.com%' OR
    url LIKE '%peekatmygirlfriend.com%' OR
    url LIKE '%hijacked.eu%' OR
    url LIKE '%detonating.com%' OR
    url LIKE '%bat5.com%' OR
    url LIKE '%xxxs.org%' OR
    url LIKE '%usercash.com%' OR
    url LIKE '%linkbucks.com%' OR
    url LIKE '%baberepublic.com%' OR
    url LIKE '%blahetc.com%' OR
    url LIKE '%linkgalleries.net%' OR
    url LIKE '%placepictures.com%' OR
    url LIKE '%picturesetc.net%' OR
    url LIKE '%qvvo.com%' OR
    url LIKE '%realfiles.net%' OR
    url LIKE '%seriousfiles.com%' OR
    url LIKE '%seriousurls.com%' OR
    url LIKE '%thatsprime.com%' OR
    url LIKE '%thesegalleries.com%' OR
    url LIKE '%thesefiles.com%' OR
    url LIKE '%ubucks.net%' OR
    url LIKE '%urlpulse.net%' OR
    url LIKE '%viraldatabase.com%' OR
    url LIKE '%youfap.com%' OR
    url LIKE '%djsuonerie.it%'

    ";

    mysql_query($queryz9) or die(mysql_error());
    }

    echo "<b>Done.</b><br><br>";

    }
    ?>
    This Button Will Clean Break Frame Ads.
    <br><br>
    <form method="post" action="index.php?op=77">
    <input type="hidden" name="clean" value="clean">
    <input type="submit" Value="Clean" class="button">
    </form>

    </table>


    <b>Clean Inactive Members</b>
    <br><br>

    <?
    if ($_POST)
    {
    $tabla5 = mysql_query("SELECT * FROM tb_users ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre

    $olddate=time() - 15552000; // 60*60*24 = 1 day * 180 = 6 months inactive (15552000)
    
    $queryz9 = "DELETE FROM tb_users WHERE lastlogdate <'$olddate'"; //comment
    mysql_query($queryz9) or die(mysql_error());
    
    echo "<b>Done.</b><br><br>";
    

    }

    ?>
    This Button Will Clean Inactive Members.
    <br><br>
    <form method="post" action="index.php?op=34">
    <input type="hidden" name="clean" value="clean">
    <input type="submit" Value="Clean" class="button">
    </form>


    <b>Clean Old Messages</b>
    <br><br>

    <?
    if ($_POST)
    {
    $tabla5 = mysql_query("SELECT * FROM tb_messenger ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre

    $olddate=time() - 2592000; // 60*60*24 = 1 day * 30 = 1 month old (2592000)
    
    $queryz9 = "DELETE FROM tb_messenger WHERE timestamp <'$olddate'"; //comment
    mysql_query($queryz9) or die(mysql_error());
    
    echo "<b>Done.</b><br><br>";
    

    }

    ?>
    This Button Will Clean Old Messages.
    <br><br>
    <form method="post" action="index.php?op=38">
    <input type="hidden" name="clean" value="clean">
    <input type="submit" Value="Clean" class="button">
    </form>


    <b>Clean Read Messages</b>
    <br><br>

    <?
    if ($_POST){

    $tabla5 = mysql_query("SELECT * FROM tb_messenger WHERE status='read' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
    while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen

    $queryz9 = "DELETE FROM tb_messenger WHERE status='read'";
    mysql_query($queryz9) or die(mysql_error());
    }

    echo "<b>Done.</b><br><br>";

    }
    ?>
    This Button Will Clean Read Messages.
    <br><br>
    <form method="post" action="index.php?op=33">
    <input type="hidden" name="clean" value="clean">
    <input type="submit" Value="Clean" class="button">
    </form>

    </table>


    <b>Clean Visits</b>
    <br><br>

    <?
    if ($_POST){

    $tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='visit' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
    while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen

    $queryz9 = "DELETE FROM tb_ads WHERE tipo='visit'";
    mysql_query($queryz9) or die(mysql_error());
    }

    echo "<b>Done.</b><br><br>";

    }
    ?>
    This Button Will Clean Old Visits.
    <br><br>
    <form method="post" action="index.php?op=32">
    <input type="hidden" name="clean" value="clean">
    <input type="submit" Value="Clean" class="button">
    </form>

    </table>


    Vorrei riunire tutte queste funzioni in 1 singola query (cleanall.php) ma non riesco a farlo, spero mi possiamo aiutare

    grazie mille, un saluto a tutti

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • C
      C
      ceccus
      scritto su ultima modifica di
      User Attivo 5
      #2

      Ciao guadagnaeuro,

      dovrebbe essere sufficiente unire tutte le query in php in un unico if che sfrutti la variabile POST clean:

      if ($_POST['clean']=='clean'){
      //tutte le query senza le condizioni if ($_POST){...}
      }

      al posto di

      if ($_POST){
      //singolo blocco
      }

      (...)

      if ($_POST){
      //singolo blocco
      }

      1 Risposta Ultima Risposta
      Miglior risposta 0
      0
      • G
        G
        guadagnaeuro
        Bannato
        scritto su ultima modifica di
        Super User 290
        #3

        Ciao ceccus

        sono ancora a livello elementare di mysql e php

        per favore puoi scrivermi il codice completo di almeno 3 query fuse?

        appena vedo il codice magari capisco come unirle tutte ma se nn me lo scrivi con almeno 3 query non lo capisco

        ti ringrazio per l'aiuto e scusami se non ti ho capito ma ancora so poco di php

        a presto e grazie

        1 Risposta Ultima Risposta
        Miglior risposta 0
        0
        • C
          C
          ceccus
          scritto su ultima modifica di
          User Attivo 5
          #4
          <b>Clean Ads</b>
          <br><br>
          
          
          <?
          if ($_POST['clean']=='clean'){
          
           
          
          $tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
          while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
          
          $igual=$registro5["plan"];
          
          //Todo parece correcto procedemos con la inserccion
          $queryz9 = "DELETE FROM tb_ads WHERE tipo='ads' AND members='$igual'";
          mysql_query($queryz9) or die(mysql_error());
          }
          
           
           
           
           
           
          $tabla5 = mysql_query("SELECT * FROM tb_ads where tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
          while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
          
          $queryz9 = "DELETE FROM tb_ads WHERE
          url LIKE '%ucash.in%' OR
          url LIKE '%urlcash.net%' OR
          url LIKE '%eightteen.com%' OR
          url LIKE '%pornyhost.com%' OR
          url LIKE '%urlcash.org%' OR
          url LIKE '%clb1.com%' OR
          url LIKE '%urlgalleries.com%' OR
          url LIKE '%celebclk.com%' OR
          url LIKE '%looble.net%' OR
          url LIKE '%smilinglinks.com%' OR
          url LIKE '%peekatmygirlfriend.com%' OR
          url LIKE '%hijacked.eu%' OR
          url LIKE '%detonating.com%' OR
          url LIKE '%bat5.com%' OR
          url LIKE '%xxxs.org%' OR
          url LIKE '%usercash.com%' OR
          url LIKE '%linkbucks.com%' OR
          url LIKE '%baberepublic.com%' OR
          url LIKE '%blahetc.com%' OR
          url LIKE '%linkgalleries.net%' OR
          url LIKE '%placepictures.com%' OR
          url LIKE '%picturesetc.net%' OR
          url LIKE '%qvvo.com%' OR
          url LIKE '%realfiles.net%' OR
          url LIKE '%seriousfiles.com%' OR
          url LIKE '%seriousurls.com%' OR
          url LIKE '%thatsprime.com%' OR
          url LIKE '%thesegalleries.com%' OR
          url LIKE '%thesefiles.com%' OR
          url LIKE '%ubucks.net%' OR
          url LIKE '%urlpulse.net%' OR
          url LIKE '%viraldatabase.com%' OR
          url LIKE '%youfap.com%' OR
          url LIKE '%djsuonerie.it%'
          
          ";
          
          mysql_query($queryz9) or die(mysql_error());
          }
          
          echo "<b>Done.</b><br><br>";
          
           
           
           
           
           
           
          $tabla5 = mysql_query("SELECT * FROM tb_users ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
          
          $olddate=time() - 15552000; // 60*60*24 = 1 day * 180 = 6 months inactive (15552000)
          
          $queryz9 = "DELETE FROM tb_users WHERE lastlogdate <'$olddate'"; //comment
          mysql_query($queryz9) or die(mysql_error());
          
          echo "<b>Done.</b><br><br>";
          
           
           
           
           
           
           
           
          $tabla5 = mysql_query("SELECT * FROM tb_messenger ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
          
          $olddate=time() - 2592000; // 60*60*24 = 1 day * 30 = 1 month old (2592000)
          
          $queryz9 = "DELETE FROM tb_messenger WHERE timestamp <'$olddate'"; //comment
          mysql_query($queryz9) or die(mysql_error());
          
          echo "<b>Done.</b><br><br>";
          
           
           
           
          $tabla5 = mysql_query("SELECT * FROM tb_messenger WHERE status='read' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
          while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
          
          $queryz9 = "DELETE FROM tb_messenger WHERE status='read'";
          mysql_query($queryz9) or die(mysql_error());
          }
          
          echo "<b>Done.</b><br><br>";
          
           
           
           
           
           
          $tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='visit' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
          while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
          
          $queryz9 = "DELETE FROM tb_ads WHERE tipo='visit'";
          mysql_query($queryz9) or die(mysql_error());
          }
          
          echo "<b>Done.</b><br><br>";
          
           
          }
           
           
          ?>
          This Button Will Clean Old Visits.
          <br><br>
          <form method="post" action="index.php?op=32">
          <input type="hidden" name="clean" value="clean">
          <input type="submit" Value="Clean" class="button">
          </form>
           
           
          </table>
          

          Te le ho unite tutte!

          1 Risposta Ultima Risposta
          Miglior risposta 0
          0
          • G
            G
            guadagnaeuro
            Bannato
            scritto su ultima modifica di
            Super User 290
            #5

            ciao

            ti confermo che la tua soluzione va bene

            grazie mille

            mi hai risolto davvero una procedura noiosa da fare ogni giorno

            grazie mille alla prossima

            ciaoooo

            1 Risposta Ultima Risposta
            Miglior risposta 0
            0

            Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

            Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

            Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

            Registrati Accedi
            Rispondi
            • Risposta alla discussione
            Effettua l'accesso per rispondere
            • Da Vecchi a Nuovi
            • Da Nuovi a Vecchi
            • Più Voti


            • Accedi

            • Non hai un account? Registrati

            • Accedi o registrati per effettuare la ricerca.
            • Primo post
              Ultimo post
            Home Accedi Registrati
            Menu
            • CATEGORIES
            • La Community Connect.gt
            • Presentati alla Community
            • News Ufficiali da Connect.gt
            • Internet News
            • A Scuola Di
            • Digital Marketing
            • Intelligenza Artificiale
            • SEO & GEO
            • Web Marketing e Content
            • Google Analytics e Web Analytics
            • Google Ads & Advertising
            • YouTube
            • TikTok, Instagram e altri Social
            • Google Adsense, Affiliazioni e Guadagno
            • E-Commerce
            • Coding e Sistemistica
            • Help Center: consigli per il tuo progetto
            • Hosting e Cloud
            • Coding
            • CMS & Piattaforme Self-Hosted
            • Annunci e Collaborazioni
            • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
            • Collaborazioni WEB e Lavoro: offro e cerco
            • Impresa, Fisco e Leggi
            • Consulenza Legale e Professioni Web
            • Consulenza Fiscale, Imprese, Startup e P.Iva
            • Gli Off Topic
            • PC, Smartphone e altri Hardware
            • Tutti i Software
            • GT Fetish Cafè
            • Discussioni
            • Non letti 0
            • Recenti
            • Hashtag
            • Popolare
            • Utenti
            • Privacy
            • Termini e condizioni
            • © 2026 Search On Media Group S.r.l.