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



<%

		Connection conn = null;
  String bandname="";
           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");
           
          String band = "";
		
            if (request.getParameter("band").equals("")) {
            System.out.println("empty.."); 
            return;
            
        } else {
            System.out.println(request.getParameter("band"));
           band=request.getParameter("band");
        
           }
           

           
      Statement s = conn.createStatement ();
			String query= ("Select * from forumposts where band_id in (select id from bands where name = \""+band+"\") ORDER by DATE DESC, TIME DESC LIMIT 10");
			System.out.println(query);			
			s.executeQuery (query);
			ResultSet rs = s.getResultSet ();
              
%>              

<div class="bbg">Name:</div><input id="nameField" type="text" size="25"><br>
<div class="bbg">Post:</div><textarea cols="20" rows="3" id="postfield">
</textarea>

<button onclick="javascript:newPost()">post!</button>
<div id="isPostForum"></div>
<br>      
<br>      

<%
      
      int idVal;
      String name="";
      String post="";
      String poster="";
      java.sql.Time time = null;
      java.sql.Date date = null;
                           
		while (rs.next ())
		{
			idVal = rs.getInt ("id");
			poster/*:)*/ = rs.getString ("name");
			post = rs.getString ("post");
			time = rs.getTime("time");
			date= rs.getDate("date");

			out.println("<div class=\"bbg2\"><u><b>"+poster+":</b></u><font size=2> "+date+" "+time+"</font></div>"+post);
			out.println("<br><br>");
			
			
			
		}
		rs.close ();
		s.close ();
      /*
      out.println(bandname);
      out.println("<br>");
      out.println("<img src=\""+picurl+"\"/>");
      out.println("<br>");
      out.println("<br>");
      out.println(desc);
      */
           
	}
           
                      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 */ }
               }
           }
           

%>




<script type="text/javascript" src="js/ajax.js"></script>
<script language="JavaScript">
<% //out.println("javascript:getAjax('myspaceplayer.jsp?band="+bandname+"','player_place');"); %>
</script>

<%
//ajax.getMyspace player = new ajax.getMyspace();

//out.println(player.getMyspacePlayer(bandname));
%>







