Hi,
Im trying to create three pages for Inserting, deleting or viewing database contents. On my main or home page the database contents are shown. I want to create a "Delete" hyperlink in the last column of every row so that the specific record is deleted on clicking that. I just knw how to create the hyperlink. I dont remember how to parse the ID of the record to be deleted. Please help.

<a href="page.jsp?id=5">Text</a>

Or for a dynamic link jsp:

<a href="page.jsp?id=<%=id%>">Text</a>

Where 'id' is a java variable

Eh.. i used a while loop. Thanx for helping me out on that line. Here is what i have.

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        The Current Table Data is :- <br>
        <%

        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        java.sql.Connection con = java.sql.DriverManager.getConnection("jdbc:odbc:WoW");
        java.sql.Statement s =con.createStatement();
        java.sql.ResultSet r =s.executeQuery("select * from Char");

                %>
                <table border="2">
                    <tr>
                        <td></td>
                        <td>Index</td>
                        <td>Character Name</td>
                        <td>Level</td>
                        <td>Location</td>
                    </tr>

               <% 
               Integer  v;
               String  url;    
               while (r.next()){

                  v=r.getInt("Roll");

                  url="<a href=Asgn1.3.jsp?id=" +  v.toString()+ ">Delete Record</a>";

                %>

               <tr>
                   <td><%=url %></td>
                   <td><%=v %></td>
                   <td><%=r.getString("Name")%></td>
                   <td><%=r.getShort("Level")%></td>
                   <td><%=r.getString("Location")%></td>

               </tr>
               <% }
                con.close();
                %>
                </table>

                <br>
                <br>

                Please Enter The Character Details Below
                <br>
        <form name="frm" action="Asgn1.2.jsp" method="get">
          Index : <input name="Roll" type="text" /> <br>
          Name  : <input name="Name" type="text" /> <br>
          Level : <input name="Level" type="text" /> <br>
          Location : <input name="Location" type="text" />
          <input type="submit" value="Save" />
      </form>

    </body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.