Section

Test Topic

Jun 13th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. <%
  2.     String catQuery = "SELECT * from categories";
  3.     Resultset result = st.executeQuery(catQuery);
  4.    
  5.     int nCol = result.getMetaData().getColumnCount();
  6.     List<String[]> catTable = new ArrayList<>();
  7.     while( result.next()) {
  8.         String[] row = new String[nCol];
  9.         for( int iCol = 1; iCol <= nCol; iCol++ ){
  10.             row[iCol-1] = result.getObject( iCol ).toString();
  11.         }
  12.         table.add( row );
  13.     }
  14.    
  15.     String topQuery = "SELECT * from topics";
  16.     result = st.executeQuery(catQuery);
  17.    
  18.     nCol = result.getMetaData().getColumnCount();
  19.     List<String[]> topTable = new ArrayList<>();
  20.     while( result.next()) {
  21.         String[] row = new String[nCol];
  22.         for( int iCol = 1; iCol <= nCol; iCol++ ){
  23.             row[iCol-1] = result.getObject( iCol ).toString();
  24.         }
  25.         table.add( row );
  26.     }
  27.    
  28.     for(String[] category: catTable){ //loops categories
  29.         //print h1 header for category
  30.         out.write("<h1>" + category[1] + "</h1><br>"); //cat[1] = cat_name in categories
  31.         /*
  32.          * Di bawah ini masukkin code HTML biar nulis Topics, Posts, Last Post
  33.          * beserta garis panjangnya
  34.          */
  35.        
  36.         for(String[] topic: topTable){ //loops topics
  37.             if(topic[3].equals(category[0]){ //topics.topic_cat == category.cat_id
  38.                 out.write("<span>" + topic[1] + "</span><br>"); //topic[1] = topic_subject in topics
  39.                 /*
  40.                  * Di bawah ini masukkin code HTML biar posisi "by admin" nya bener di pojok sana.
  41.                  */
  42.             }
  43.         }
  44.     }
  45. %>
Advertisement
Add Comment
Please, Sign In to add comment