Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833

    Ciclo di lettura nidificato, non mi funziona

    Ciao a tutti, ho un problema che riesco a risolvere e spero che mi aiutate voi perche' e' da piu' di un'ora che ci sbatto la testa.
    Vi spiego cosa devo fare, devo leggere tutti i clienti di un partner e poi devo leggere per ogni cliente del partner tutti i suoi server. Le istruzioni mi sembrano giuste, il primo ciclo legge i clienti del partner e il secondo legge e stampa i server del cliente.
    IL problema e' che vengono fuori solo i server del primo cliente, poi e' come se non facesse
    la seconda lettura nel primo statement.

    Forse non stato molto chiaro, posto il codice, magari e' piu' facile capire cosi', in caso ditemi
    in cosa non mi sono spiegato, cosi' cerchero' di esserre piu' chiaro.
    Ciao e grazie



    $customerCLSCLI = $_SESSION['customerCLSCLI'];

    /* Costruzione dello statement SQL da eseguire */

    $sql = "select *
    from ACSSI_DAT.clssi00f
    where clsprt = '$_SESSION[customerCLSCLI]'
    and clsatv <> 'A'

    ";

    /* Esecuzione diretta dello stament SQL */
    $stmt = db2_exec($dbh, $sql, array('cursor' => DB2_SCROLLABLE));




    while ($row = db2_fetch_array($stmt)) {
    if (!$row=="") {
    $customerCLSCLO = $row[7];


    echo "Variabile sessione = ".$customerCLSCLI."
    ";


    /* Costruzione dello statement SQL da eseguire */

    $sql = "select *
    from ACSSI_DAT.sercl00f
    where sercli = '$customerCLSCLO'
    and seratv <> 'A'

    ";

    /* Esecuzione diretta dello stament SQL */
    $stmt = db2_exec($dbh, $sql, array('cursor' => DB2_SCROLLABLE));

    print '<table border=0 cellpadding6 cellspacing=0 bgcolor="#F7F7F7" bordercolor="#F7F7F7">';


    while ($row = db2_fetch_array($stmt)) {
    if (!$row=="") {
    $customerSERCLI = $row[7];
    $customerSERSRN = $row[8];
    $customerSERNSP = $row[10];
    $customerSERMOD = $row[9];
    $customerSERPRO = $row[14];
    $customerSERVRS = $row[15];
    $customerSERBLD = $row[20];
    $customerSERASP = $row[19];
    $customerSERREL = $row[18];
    ?>



    <tr>


    <?php if ($contatore=='1'){
    ?>


    <td bgcolor="#CCCCCC" align="left" width="108">
    <a href="srvrq10.php?customerSERCLI=<?php echo($customerSERCLI);?>
    &customerSERSRN=<?php echo($customerSERSRN);?>
    &customerSERNSP=<?php echo($customerSERNSP);?>
    &customerSERMOD=<?php echo($customerSERMOD);?>
    &customerSERPRO=<?php echo($customerSERPRO);?>
    &customerSERVRS=<?php echo($customerSERVRS);?>
    &customerSERBLD=<?php echo($customerSERBLD);?>
    &customerSERASP=<?php echo($customerSERASP);?>
    &customerSERREL=<?php echo($customerSERREL);?>"'>

    <?php echo ($customerSERCLI);?></a>
    </td>


    <td width="110" bgcolor="#CCCCCC"><?php echo($customerSERSRN);?></td>
    <td width="110" bgcolor="#CCCCCC"><?php echo($customerSERNSP);?></td>
    <td width="170" bgcolor="#CCCCCC"><?php echo($customerSERMOD);?></td>
    <td width="110" bgcolor="#CCCCCC"><?php echo($customerSERPRO);?></td>
    <td width="60" bgcolor="#CCCCCC"><?php echo($customerSERVRS);?></td>
    </td>

    <?php
    }
    ?>


    <?php if ($contatore=='2'){
    ?>

    <td bgcolor="#F7F7F7" align="left" width="110">
    <a href="srvrq10.php?customerSERCLI=<?php echo($customerSERCLI);?>
    &customerSERSRN=<?php echo($customerSERSRN);?>
    &customerSERNSP=<?php echo($customerSERNSP);?>
    &customerSERMOD=<?php echo($customerSERMOD);?>
    &customerSERPRO=<?php echo($customerSERPRO);?>
    &customerSERVRS=<?php echo($customerSERVRS);?>
    &customerSERBLD=<?php echo($customerSERBLD);?>
    &customerSERASP=<?php echo($customerSERASP);?>
    &customerSERREL=<?php echo($customerSERREL);?>"'>

    <?php echo ($customerSERCLI);?></a>
    </td>


    <td width="110" bgcolor="#F7F7F7"><?php echo($customerSERSRN);?></td>
    <td width="110" bgcolor="#F7F7F7"><?php echo($customerSERNSP);?></td>
    <td width="170" bgcolor="#F7F7F7"><?php echo($customerSERMOD);?></td>
    <td width="110" bgcolor="#F7F7F7"><?php echo($customerSERPRO);?></td>
    <td width="60" bgcolor="#F7F7F7"><?php echo($customerSERVRS);?></td>
    </td>

    <?php
    }
    ?>


    <?php if ($contatore=='1'){
    $contatore='2';
    }
    else{
    $contatore='1';
    }
    ?>



    </tr>




    <?php


    }

    }

    }

    }





    print '</table>
    ';
    if ($customerSERCLI=="") {
    ?>



    <font size="4">


    "Non presenti richieste di assistenza"</font>


    <?php
    }
    ?>

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    833
    Mi autorispondo, in caso servisse a qualcun altro, il problema era che facevo in tutti e due gli statement $stmt = db2_exec($dbh, $sql, array('cursor' => DB2_SCROLLABLE));

    e ovviamente quando finivano i record nella seconda lettura e tornavo a leggere la prima
    queste istruzioni, while ($row = db2_fetch_array($stmt)) { if (!$row=="") erano a blanks
    perche' le avevo usate anche nell'altra.

    Ho risolto semplicemente definendo il secondo ciclo con queste variabili

    $stmt1 = db2_exec($dbh, $sql, array('cursor' => DB2_SCROLLABLE));
    while ($row = db2_fetch_array($stmt1)),

    Grazie comunque, ciao.

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.