View difference between Paste ID: fvkfx3qq and 4hpHaLy0
SHOW: | | - or go back to the newest paste.
1
<%
2
    //follow2an-bricked
3
4
    //balikin value UID dari session
5-
    ResultSet rs3 = st.executeQuery("SELECT * FROM msuser WHERE username = '"+username2+"'");
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.followedID='"+uidsession+"'");
11+
    ResultSet rs4 = st.executeQuery("SELECT * FROM following WHERE following.followedID='"+userid+"' AND following.followingID='"+uidsession+"'");
12-
    rs4.next();
12+
    rs4.next(); // userid = followed 
13
14
	
15
    //validasi tombol
16
	String jspFollow = "";
17-
    if(!session.getAttribute("name").equals(rs2.getString("username"))) 
17+
	String textFollow = "";
18
	
19
    if(!session.getAttribute("name").equals(rs2.getString("username"))) {
20-
    if(!uidsession.equals(rs4.getString("followID")) && !userid.equals(rs4.getString("followingID")))
20+
21-
      //<- bandingin id session = id following di tabel followers ga
21+
22-
      //<- bandingin userid page profile = id followed di tabel followers ga
22+
		if(!uidsession.equals(rs4.getString("followID")) && !userid.equals(rs4.getString("followingID")))
23-
    {
23+
		//<- bandingin id session = id following di tabel followers ga
24-
    %>
24+
		//<- bandingin userid page profile = id followed di tabel followers ga
25-
    <a href="doFollow.jsp?UID=<%=userid%>" class="btn btn-lg btn-primary btn-block" type="submit">Follow</a>
25+
		{
26-
    <%
26+
			jspFollow = "doFollow.jsp=UID=" + userid;
27-
    }
27+
			textFollow = "Follow";
28-
    else
28+
		}
29-
    {
29+
		else
30-
    %>
30+
		{
31-
    <a href="doUnFollow.jsp?UID=<%=userid%>" class="btn btn-lg btn-primary btn-block" type="submit">Unfollow</a>
31+
			jspFollow = "doUnFollow.jsp?UID=" + userid;
32-
    <%
32+
			textFollow = "Unfollow";
33-
  } 
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
    %>