Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    contare i record associati

    Ho realizzato un piccolo blog. Il database in access è composto da due tabelle... Blog e commenti. Con il codice in basso visualizzo i blog presenti nel database, poi cliccando su commenti visualizzo i singoli commenti associati al blog. Fin qui tutto bene. Volevo inserire accanto al link commenti l'effettivo numero di commenti esistenti... come si fa? Devo creare un nuovo record set... non ci riesco... mi date una mano? Grazie
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

    <%
    var RecPagine = Server.CreateObject("ADODB.Recordset");
    RecPagine.ActiveConnection = MM_conn_euro_STRING;
    RecPagine.Source = "SELECT * FROM Blog ORDER BY Data DESC";
    RecPagine.CursorType = 0;
    RecPagine.CursorLocation = 2;
    RecPagine.LockType = 1;
    RecPagine.Open();
    var RecPagine_numRows = 0;

    %>

    <%
    var Repeat1__numRows = -1;
    var Repeat1__index = 0;
    RecPagine_numRows += Repeat1__numRows;
    %>
    <%
    // *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    // set the record count
    var RecPagine_total = RecPagine.RecordCount;

    // set the number of rows displayed on this page
    if (RecPagine_numRows < 0) { // if repeat region set to all records
    RecPagine_numRows = RecPagine_total;
    } else if (RecPagine_numRows == 0) { // if no repeat regions
    RecPagine_numRows = 1;
    }

    // set the first and last displayed record
    var RecPagine_first = 1;
    var RecPagine_last = RecPagine_first + RecPagine_numRows - 1;

    // if we have the correct record count, check the other stats
    if (RecPagine_total != -1) {
    RecPagine_numRows = Math.min(RecPagine_numRows, RecPagine_total);
    RecPagine_first = Math.min(RecPagine_first, RecPagine_total);
    RecPagine_last = Math.min(RecPagine_last, RecPagine_total);
    }
    %>

    <%
    // *** Recordset Stats: if we don't know the record count, manually count them

    if (RecPagine_total == -1) {

    // count the total records by iterating through the recordset
    for (RecPagine_total=0; !RecPagine.EOF; RecPagine.MoveNext()) {
    RecPagine_total++;
    }

    // reset the cursor to the beginning
    if (RecPagine.CursorType > 0) {
    if (!RecPagine.BOF) RecPagine.MoveFirst();
    } else {
    RecPagine.Requery();
    }

    // set the number of rows displayed on this page
    if (RecPagine_numRows < 0 || RecPagine_numRows > RecPagine_total) {
    RecPagine_numRows = RecPagine_total;
    }

    // set the first and last displayed record
    RecPagine_last = Math.min(RecPagine_first + RecPagine_numRows - 1, RecPagine_total);
    RecPagine_first = Math.min(RecPagine_first, RecPagine_total);
    }
    %>
    <html>
    <body>
    <% while ((Repeat1__numRows-- != 0) && (!RecPagine.EOF)) { %>
    <h2><%=(RecPagine.Fields.Item("Titolo").Value)%> </h2>
    <%=(RecPagine.Fields.Item("Testo").Value)%>
    <p class="postato">Postato il <span class="evid2"><%=(RecPagine.Fields.Item("Data").Va lue)%></span> | " tabindex="50">Scrivi | " tabindex="50">Commenti | </p>


    </p>
    <%
    Repeat1__index++;
    RecPagine.MoveNext();
    }
    %>
    </body>
    </html>

  2. #2
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    ma perchè postare queti obrobri.. nativi da dreamweaver

    SELECT COUNT (*) AS CONTACOMMENTI FROM MIA_TBL WHERE ID="&ID&"

    CREDO SIA CORRETTA...

  3. #3
    perchè postare questi obrobri? forse perche funzionano

  4. #4
    Utente di HTML.it L'avatar di agenti
    Registrato dal
    Feb 2002
    Messaggi
    2,427
    appesantisce di 100 volte la pagina...

    quello che hai scritto può essere alleggerito notevolmente.

    usa asp puro.... è meglio per tutti.
    anche per chi ti vorebbe aiutare.

  5. #5
    di 100 volte non mi pare proprio visto che la pagina si apre velocemente anche con una linea analogica... Comunque sto cercando di imparare asp per cui di riflesso abbondonerò il codice di dw. Ma per adesso mi è di grande aiuto

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.