problem with shopping cart
by , 08-29-2012 at 02:15 PM (1549 Views)
how do i increase the quatity of an item when it is added again and again into my shopping cart table.there is only a button add to cart.there is no textfeild for quantitiy.
the code as of now i have retreives the items from database and add it into the shipping cart table. if i clik on it again and again the same item wil be shown again and again.
Java Code:DefaultTableModel model = (DefaultTableModel) tbl1.getModel(); DefaultTableModel tm = (DefaultTableModel) tbl2.getModel(); int a = tbl1.getSelectedRow(); if (a == 0) { try { Class.forName("java.sql.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/album", "root", "123"); Statement stm = con.createStatement(); String sql = "select ALBUMNAME,PRICE FROM albums WHERE ALBUMNAME='twilight' ;"; ResultSet res = stm.executeQuery(sql); while (res.next()) { String ALBUMNAME = res.getString("ALBUMNAME"); int PRICE = res.getInt ("PRICE"); tm.addRow(new Object[]{ALBUMNAME, PRICE}); } res.close(); con.close(); stm.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "error in connectivity"); }









Email Blog Entry
Size Reduced for Images in PDF &...
05-15-2013, 05:53 PM in Java Software