Section

Untitled

Jun 7th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  10.     //balikin tabel following
  11.     ResultSet rs4 = st.executeQuery("SELECT * FROM following WHERE following.followedID='"+userid+"' AND following.followingID='"+uidsession+"'");
  12.     rs4.next(); // userid = followed
  13.  
  14.    
  15.     //validasi tombol
  16.     String jspFollow = "";
  17.     String textFollow = "";
  18.    
  19.     if(!session.getAttribute("name").equals(rs2.getString("username"))) {
  20.       //<- bandingin ID profile = id session apa engga. kalo sama ga muncul tombol follownya
  21.  
  22.         if(!uidsession.equals(rs4.getString("followID")) && !userid.equals(rs4.getString("followingID")))
  23.         //<- bandingin id session = id following di tabel followers ga
  24.         //<- bandingin userid page profile = id followed di tabel followers ga
  25.         {
  26.             jspFollow = "doFollow.jsp=UID=" + userid;
  27.             textFollow = "Follow";
  28.         }
  29.         else
  30.         {
  31.             jspFollow = "doUnFollow.jsp?UID=" + userid;
  32.             textFollow = "Unfollow";
  33.        
  34.         }
  35.         out.write("<a href=\"" + jspFollow + "\"class=\"btn btn-lg btn-primary btn-block\" type=\"submit\">" + textFollow + "</a>");
  36.     }
  37.     //follow2an-bricked-end
  38.     %>
Add Comment
Please, Sign In to add comment