Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14

Discussione: Condizione...

  1. #1

    Condizione...

    Salve a tutti...
    Ho un menu che recupera categorie e sotto categorie dal Db
    Cat_id | Cat_parent | Cat_name |
    1 0 Monitor
    2 1 Lcd
    3 1 Crt
    3 1 Computer

    adesso nella visualizzazione
    avro che Lcd e Crt sono sottocategorie di Monitor
    Computer non ha sottocategorie
    quindi a rigor di logica la categoria principale Monitor io vorrei che non fosse cliccabile perchè lo sono le sue sottocategorie (Lcd e Crt)
    mentre la categoria Computer che non ha sottocategorie deve essere cliccabile.

    Ho provato con la condizione che vedete nel seguente codice dicendo che se wsub_categ = "0" deve darmi il link sulla categoria, differentemente no!

    Ebbene non funziona, nessun errore, mi da il collegamento in entrambe le condizioni, ovvero sia che sia uguale a 0 che differentemente!

    Qualche idea o consiglio?

    Codice PHP:
    <% if wsub_categ "0" then %>[b]
                    <
    a href="../pictures/cat.asp?iCat=<%=(rsDefaultCats.Fields.Item("CAT_ID").Value)%>">
                    <%=(
    rsDefaultCats.Fields.Item("CAT_NAME").Value)%>
                    </
    a>[/b]
                    <%else%>
                    [
    b]<%=(rsDefaultCats.Fields.Item("CAT_NAME").Value)%>[/b] (<%=(rsCatCount.Fields.Item("PIC_COUNT").Value)%>)
                    <%
    end if%>
                    

                     <%
    rsCatCount.Close()
    Set rsCatCount Nothing
    %> 
                      
    <%
    Dim rsDefaultSubs__numRows
    rsDefaultSubs__numRows 
    3
    Dim rsDefaultSubs__index
    rsDefaultSubs__index 
    0
    rsDefaultSubs_numRows 
    rsDefaultSubs_numRows rsDefaultSubs__numRows
    rsDefaultSubs
    .Filter "CAT_PARENT=" rsDefaultCats.Fields.Item("CAT_ID").Value
    %>
                      <% While ((
    rsDefaultSubs__numRows <> 0) AND (NOT rsDefaultSubs.EOF)) %>
                      [
    url='../pictures/cat.asp?iCat=<%=(rsDefaultSubs.Fields.Item("CAT_ID").Value)%>']<%=(rsDefaultSubs.Fields.Item("CAT_NAME").Value)%>[/url]
                      <% If 
    rsDefaultSubs__index 0 Then Response.Write(" ...") Else Response.Write(", "End If %>
                      <%
      
    rsDefaultSubs__index=rsDefaultSubs__index+1
      rsDefaultSubs__numRows
    =rsDefaultSubs__numRows-1
      rsDefaultSubs
    .MoveNext()
    Wend
    %> 
    Scusate sto imparando!

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    wsub_categ dove lo prendi?

    Roby

  3. #3
    Ciao roby, ho pensato di volorizzaro, e lo faccio all'inizio, ecco il codice:

    Codice PHP:


    <%
    set rsDefaultCats Server.CreateObject("ADODB.Recordset")
    rsDefaultCats.ActiveConnection MM_conn_STRING
    rsDefaultCats
    .Source "SELECT *  FROM CATEGORIES  WHERE CAT_PARENT = 0 AND CAT_ACTIVE = 1  ORDER BY CAT_NAME ASC"
    rsDefaultCats.CursorType 0
    rsDefaultCats
    .CursorLocation 2
    rsDefaultCats
    .LockType 3
    rsDefaultCats
    .Open()
    rsDefaultCats_numRows 0

    wsub_categ
    =rsDefaultCats("CAT_PARENT")

    %>
    <%
    set rsDefaultSubs Server.CreateObject("ADODB.Recordset")

    rsDefaultSubs.ActiveConnection MM_connIWGallery_STRING
    rsDefaultSubs
    .Source "SELECT * FROM CATEGORIES WHERE CAT_ACTIVE = 1  ORDER BY CAT_NAME ASC"
    rsDefaultSubs.CursorType 0
    rsDefaultSubs
    .CursorLocation 2
    rsDefaultSubs
    .LockType 3
    rsDefaultSubs
    .Open()
    rsDefaultSubs_numRows 0
    %>
    <%
    Dim HLooper1__numRows
    HLooper1__numRows 
    = -2
    Dim HLooper1__index
    HLooper1__index 
    0
    rsDefaultCats_numRows 
    rsDefaultCats_numRows HLooper1__numRows
    %> 
    poi dopo fa altre cose e arriva il codice postato all'inizio!
    Scusate sto imparando!

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    if cstgr(wsub_categ) = "0" then

    Roby

  5. #5
    Errore di run-time di Microsoft VBScript error '800a000d'

    Tipo non corrispondente: 'cstgr'

    /home/inc_categorie.asp, line 74

    line 74 <% if cstgr(wsub_categ) = "0" then %>
    Scusate sto imparando!

  6. #6
    un errorozzo di battitura....


    o fai

    if cstr(wsub_categ) = "0" then

    oppure

    if cint(wsub_categ) = 0 then


  7. #7
    fixato l'errore di battitura, in entrambi i casi non risolvo il mio problema...
    la categoria madre di Monitor è ancora cliccabile
    Scusate sto imparando!

  8. #8
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Scusa per l'errore...
    Togli la condizione e stampa accanto alla categoria il valore di wsub_categ:
    codice:
    <%=(rsDefaultCats.Fields.Item("CAT_NAME").Value &" - "& wsub_categ)%>
    Verifica cosa stampa...

    Roby

  9. #9
    Ciao Roby... no problem, la stanchezza fa brutti scherzi
    avevo pensato anche io a vedere cosa effettivamente vedeva wsub_categ, ed ecco la risposta:

    vede tutti i valori 0 (zero) ecco perche mi mette il collegamento anche sulle categorie che hanno le sottoc....

    Sbaglio quindi a valorizzare la sotto categoria??

    ti posto un po di codice della pagina
    Codice PHP:
    <%
    set rsDefaultCats Server.CreateObject("ADODB.Recordset")
    rsDefaultCats.ActiveConnection MM_connMaxConn_STRING
    rsDefaultCats
    .Source "SELECT *  FROM CATEGORIES  WHERE CAT_PARENT = 0 AND CAT_ACTIVE = 1  ORDER BY CAT_NAME ASC"
    rsDefaultCats.CursorType 0
    rsDefaultCats
    .CursorLocation 2
    rsDefaultCats
    .LockType 3
    rsDefaultCats
    .Open()
    rsDefaultCats_numRows 0
    wsub_categ
    =rsDefaultCats("CAT_PARENT"' questo e anche inutile, possiamo recuperare diversamente questo valore

    %>
    <%
    set rsDefaultSubs = Server.CreateObject("ADODB.Recordset")

    rsDefaultSubs.ActiveConnection = MM_connMaxConn_STRING
    rsDefaultSubs.Source = "SELECT * FROM CATEGORIES WHERE CAT_ACTIVE = 1  ORDER BY CAT_NAME ASC"
    rsDefaultSubs.CursorType = 0
    rsDefaultSubs.CursorLocation = 2
    rsDefaultSubs.LockType = 3
    rsDefaultSubs.Open()
    rsDefaultSubs_numRows = 0
    %>
    <%
    Dim HLooper1__numRows
    HLooper1__numRows = -2
    Dim HLooper1__index
    HLooper1__index = 0
    rsDefaultCats_numRows = rsDefaultCats_numRows + HLooper1__numRows
    %>

    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td align="left" valign="top">
        <% If Not rsDefaultCats.EOF Or Not rsDefaultCats.BOF Then %>
          <table width="150"  border="0" cellspacing="1" cellpadding="0" class="content">
            <tr>
              <td>Categorie</td>
            </tr>
          </table>
          <table width="100%">
            <%
    startrw = 0
    endrw = HLooper1__index
    numberColumns = 1     '
    Qui era 2
    numrows 
    = -1
    while((numrows <> 0) AND (Not rsDefaultCats.EOF))
        
    startrw endrw 1
        endrw 
    endrw numberColumns
     
    %>
            <
    tr align="center" valign="top">
              <%
    While ((
    startrw <= endrw) AND (Not rsDefaultCats.EOF))

    strCatId rsDefaultCats.Fields.Item("CAT_ID").Value
    set rsCatCount 
    Server.CreateObject("ADODB.Recordset")
    rsCatCount.ActiveConnection MM_connMaxConn_STRING
    rsCatCount
    .Source "SELECT COUNT(*) AS PIC_COUNT  FROM PICTURES  WHERE PIC_LISTING LIKE '%." strCatId ".%' AND PIC_APPROVED = 1 AND PIC_ACTIVE = 1"
    rsCatCount.CursorType 0
    rsCatCount
    .CursorLocation 2
    rsCatCount
    .LockType 3
    rsCatCount
    .Open()
    rsCatCount_numRows 0

    %>
    <
    td width="50%" align="left" valign="top">
    <
    table  border="0" cellspacing="0" cellpadding="0" class="content">
        <
    tr>
                    <
    td valign="baseline">
                    [
    img]../images/arrows.jpg[/img]</td>
                    <
    td>
                    [
    b]
                    <
    a href="../pictures/cat.asp?iCat=<%=(rsDefaultCats.Fields.Item("CAT_ID").Value)%>">
                    <%=(
    rsDefaultCats.Fields.Item("CAT_NAME").Value &" - "wsub_categ)%>
                    </
    a>
                    [/
    b]
                     (<%=(
    rsCatCount.Fields.Item("PIC_COUNT").Value)%>)

                    

                     <%
    rsCatCount.Close()
    Set rsCatCount Nothing
    %> 
                      
    <%
    Dim rsDefaultSubs__numRows
    rsDefaultSubs__numRows 
    3
    Dim rsDefaultSubs__index
    rsDefaultSubs__index 
    0
    rsDefaultSubs_numRows 
    rsDefaultSubs_numRows rsDefaultSubs__numRows
    rsDefaultSubs
    .Filter "CAT_PARENT=" rsDefaultCats.Fields.Item("CAT_ID").Value
    %>
                      <% While ((
    rsDefaultSubs__numRows <> 0) AND (NOT rsDefaultSubs.EOF)) %>
                      [
    url='../pictures/cat.asp?iCat=<%=(rsDefaultSubs.Fields.Item("CAT_ID").Value)%>']<%=(rsDefaultSubs.Fields.Item("CAT_NAME").Value)%>[/url]
                      <% If 
    rsDefaultSubs__index 0 Then Response.Write(" ...") Else Response.Write(", "End If %>
                      <%
      
    rsDefaultSubs__index=rsDefaultSubs__index+1
      rsDefaultSubs__numRows
    =rsDefaultSubs__numRows-1
      rsDefaultSubs
    .MoveNext()
    Wend
    %> 
    Grazie
    Scusate sto imparando!

  10. #10
    Qualche idea?
    con l'ultimo consiglio di Roby
    riesco a stampare a video il valore della tabella CAT_PARENT
    per vedere il suo contenuto e mi da a tutti 0
    nonostante non sia cosi

    Come recupero il valore CAT_PARENT per creare la mia condizione!??

    Grazias
    Scusate sto imparando!

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 © 2026 vBulletin Solutions, Inc. All rights reserved.