<%@ page language = "java"%>
<%@ page import = "java.util.*"%>
<%@ page import = "java.sql.*"%>
<%@ page import = "java.io.*"%>
<%@ page import = "java.net.*"%>


<link rel="stylesheet" href="css/mysite.css" type="text/css"/>
<script type="text/javascript" src="js/ajax.js"></script>

<%

  String tag = "";
		Connection conn = null;
  
           try
           {
               String userName = "root";
               String password = "";
               String url = "jdbc:mysql://localhost/band";
               Class.forName ("com.mysql.jdbc.Driver").newInstance();
               conn = DriverManager.getConnection (url, userName, password);
               System.out.println ("Database connection established");
           
			
		
            if (request.getParameter("tag").equals("")) {
            System.out.println("empty.."); 
            return;
            
            
            
        } else {
            System.out.println(request.getParameter("tag"));
           tag=request.getParameter("tag");
           System.out.println(tag);
           }
           
           
           
/*******************************************/
           
      Statement s = conn.createStatement ();
      // 
			String query= ("select name from bands where id in (select band_id from tagged where tag_id in (select id from tags where name = '"+tag+"')) ORDER BY name");
			System.out.println(query);			
					
			s.executeQuery (query);
			ResultSet rs = s.getResultSet ();
              
              
       
      
      String bandname="";
      
      out.println("<div class=\"left50\">");
      
      out.println("<br><b>Bands tagged as: </b>"+tag+"<br><br>");
      out.println("<div class=\"bandtags\">");
		while (rs.next ())
		{
			bandname = rs.getString ("name");
			out.println("<div class=\"suggest_link\" onmouseover=\"javascript:suggestOver(this);\" onmouseout=\"javascript:suggestOut(this);\" onclick=\"javascript:getBand('"+bandname+"'); enableForum(); \"/>");
      out.println(bandname+"<br>");      
      out.println("</div>");      
		}
		
      out.println("</div>");
		out.println("</div>");
		rs.close ();
		s.close ();

		

   
   
           
	}                   catch (Exception e)
           {
               System.err.println ("database error");
               System.err.println (e);
           }
           
           finally
           {
               if (conn != null)
               {
                   try
                   {
                       conn.close ();
                       System.out.println ("Database connection terminated");
                   }
                   catch (Exception e) { /* ignore close errors */ }
               }
           }
           

%>


<div class="right50">

Add more tags:
<br><br>
and/or ->
  <select id="combobox"/>
    <option value="and"/>and
    <option value="or"/>or
  </select>

<form id="moretags_form">
<%
String andor="null";
out.println("<br><br> <input type=\"text\" onkeyup=\"moreTags('"+andor+"','"+tag+"')\" name=\"what\" id=\"what\" />");

%>
<div id="moretagssugg" class="searchmore_suggest"></div>
</form>
</div>








