Results 1 to 7 of 7
Thread: help with shoppingcart
-
help with shoppingcart
[QUOTE]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.
I HAVE A COLUMN NAME QUANTITY. THE NUMBER SHOULD INCREASE WHEN THE SAME ITEM IS ADDED.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/bollywood", "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"); }Last edited by blustar angel; 08-29-2012 at 03:35 PM.
- 08-29-2012, 04:06 PM #2
Re: help with shoppingcart
You need to have a way to test if the item is already being shown.
If not, add it with a quantity of 1
If it is shown, increment the quantity by 1If you don't understand my response, don't ignore it, ask a question.
-
Re: help with shoppingcart
how do i test if the item is shown .can you give me begining.
- 08-29-2012, 04:42 PM #4
Re: help with shoppingcart
Post a small simple program that compiles, executes and shows the problem. Something that can be worked with to see how to solve your problem.
If you don't understand my response, don't ignore it, ask a question.
-
Re: help with shoppingcart
sorry ,i dint get u.
- 08-29-2012, 05:09 PM #6
Re: help with shoppingcart
I don't understand what you don't get about my post#4.
For testing I need a small, complete program that compiles,
and executes
and shows the problem.
You need to create a small program I can use for testing the problem and working on a solution.
See: http://sscce.org/If you don't understand my response, don't ignore it, ask a question.
- 08-29-2012, 05:13 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: help with shoppingcart
Go through the table and see if there's a row in there containing the data already?
The API has at least one good method to get you started on that...Please do not ask for code as refusal often offends.


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks