2 Replies - 843 Views - Last Post: 03 March 2010 - 07:25 AM Rate Topic: ***** 1 Votes

#1 bigz008   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 38
  • Joined: 17-September 09

Trouble getting records from query and displaying

Posted 02 March 2010 - 08:26 AM

Hi, I'm creating a page in which an admin can add multiple records in one table. However, I cannot display multiple records because when I add a record from SQL, it just replaces my other records instead of adding a new row:

FULL CODE:
<% 
           String skuResult[][];
           skuResult = null;
        try {
   
String []  skuFields = {"orgID", "length", "amount", "trial_period", "promoMins"};
CRUD skuCRUD = new CRUD ("sku", "skuID");  
     skuResult = skuCRUD.getRecords(skuFields,0,0);

        } catch (Exception e) { 
Tracer.logERROR("[sku/skuContent.jsp] "+e);
        e.printStackTrace();            }             

    String    skuID="";  
    String    organisationID="";  
    String    cc_flag="";       
    String    length="";  
    String    amount="";  
    String    active="";  
    String    trialPeriod="";  
    String    description="";  
    String    promoText="";  
    String    promoMinutes="";  


for (int i = 0; i < skuResult.length; i++) {
organisationID = skuResult[i][0]; 
length = skuResult[i][1] ;
amount = skuResult[i][2];
trialPeriod = skuResult[i][3];
promoMinutes = skuResult[i][4];
%> 

<%     Tracer.logERROR("[sku/skContent.jsp] "+"errors are after this"); } %>

<table style="width: 99%">
<tr>
<td style="width: 85px;" id="tableheadercell">Organsation ID</td>
<td style="width: 50px;" id="tableheadercell">Length</td>
<td style="width: 50px;" id="tableheadercell">Amount</td>
<td style="width: 80px;" id="tableheadercell">Trial Period</td>
<td style="width: 100px;" id="tableheadercell">Promo Minutes </td>                              
</tr>

<tr>
<td style="width: 85px"><b><%= organisationID %></b></td>
<td style="width: 50px"><b><%= length %></b></td>
<td style="width: 50px"><b><%= amount %></b></td>
<td style="width: 80px"><b><%= trialPeriod %></b></td>
<td style="width: 100px"><b><%= promoMinutes %></b></td>
</tr>
</table>                                
</html>




Basically, what I want is to be able to display multiple records in the database in multiple rows. So far I can only display one:

Attached Image

Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Trouble getting records from query and displaying

#2 designthedesign   User is offline

  • New D.I.C Head

Reputation: 13
  • View blog
  • Posts: 47
  • Joined: 30-September 09

Re: Trouble getting records from query and displaying

Posted 02 March 2010 - 12:24 PM

View Postbigz008, on 02 March 2010 - 07:26 AM, said:

However, I cannot display multiple records because when I add a record from SQL, it just replaces my other records instead of adding a new row:


Does your database actually show the new entries? How do you insert them into the datbase?
Was This Post Helpful? 0
  • +
  • -

#3 bigz008   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 38
  • Joined: 17-September 09

Re: Trouble getting records from query and displaying

Posted 03 March 2010 - 07:25 AM

ok, I got it, I had to put the Table inside the for loop.

View Postdesignthedesign, on 02 March 2010 - 11:24 AM, said:

View Postbigz008, on 02 March 2010 - 07:26 AM, said:

However, I cannot display multiple records because when I add a record from SQL, it just replaces my other records instead of adding a new row:


Does your database actually show the new entries? How do you insert them into the datbase?

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1