Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%
- String catQuery = "SELECT * from categories";
- Resultset result = st.executeQuery(catQuery);
- int nCol = result.getMetaData().getColumnCount();
- List<String[]> catTable = new ArrayList<>();
- while( result.next()) {
- String[] row = new String[nCol];
- for( int iCol = 1; iCol <= nCol; iCol++ ){
- row[iCol-1] = result.getObject( iCol ).toString();
- }
- table.add( row );
- }
- String topQuery = "SELECT * from topics";
- result = st.executeQuery(catQuery);
- nCol = result.getMetaData().getColumnCount();
- List<String[]> topTable = new ArrayList<>();
- while( result.next()) {
- String[] row = new String[nCol];
- for( int iCol = 1; iCol <= nCol; iCol++ ){
- row[iCol-1] = result.getObject( iCol ).toString();
- }
- table.add( row );
- }
- for(String[] category: catTable){ //loops categories
- //print h1 header for category
- out.write("<h1>" + category[1] + "</h1><br>"); //cat[1] = cat_name in categories
- /*
- * Di bawah ini masukkin code HTML biar nulis Topics, Posts, Last Post
- * beserta garis panjangnya
- */
- for(String[] topic: topTable){ //loops topics
- if(topic[3].equals(category[0]){ //topics.topic_cat == category.cat_id
- out.write("<span>" + topic[1] + "</span><br>"); //topic[1] = topic_subject in topics
- /*
- * Di bawah ini masukkin code HTML biar posisi "by admin" nya bener di pojok sana.
- */
- }
- }
- }
- %>
Advertisement
Add Comment
Please, Sign In to add comment