Section

Untitled

Jun 7th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. <%
  2.     //follow2an-bricked
  3.  
  4.     //balikin value UID dari session
  5.     ResultSet rs3 = st.executeQuery("SELECT * FROM msuser WHERE username = '"+username2+"'"); //username2 = follower
  6.     rs3.next();
  7.     String uidsession = rs3.getString("UID");
  8.  
  9.     //validasi tombol
  10.     String jspFollow = "";
  11.     String textFollow = "";
  12.  
  13.     //balikin tabel following
  14.     ResultSet rs4 = st.executeQuery("SELECT COUNT(*) FROM following where followID ='" + username2 +"' AND followedID='" + userid + "'" );
  15.     int numOfSelection = Integer.parseInt(rs4.next());
  16.     if(!uidsession.equals(userid))
  17.      
  18.       {
  19.       //<- bandingin ID profile = id session apa engga. kalo sama ga muncul tombol follownya
  20.  
  21.       if(numOfSelection == 0)
  22.         //<- ngecek kalo di DB si username2 pernah ngefollow userid ato nggak
  23.               {
  24.                   jspFollow = "doFollow.jsp?UID=" + userid;
  25.                   textFollow = "Follow";
  26.               }
  27.          else
  28.              //<-- kalo di DB ada data klo si username2 pernah ngefollow userid
  29.               {
  30.  
  31.                   jspFollow = "doUnFollow.jsp?UID=" + userid;
  32.                   textFollow = "Unfollow";
  33.               }
  34.         out.write("<a href=\"" + jspFollow + "\"class=\"btn btn-lg btn-primary btn-block\" type=\"submit\">" + textFollow + "</a>");
  35.         break;
  36.      }
  37.     }
  38.     %>
Advertisement
Add Comment
Please, Sign In to add comment