SunQuest
 
           .NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 18th, 2001, 08:04 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,578 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
asp table formatting

<i><b>Originally posted by : Paul (paul.carey@hmv.co.uk)</b></i><br /><br /> I have a table consisting of 5 columns and 'x' records in an access database. I have connected and can display the records with headers with the following code:<br /><br />set rs = Server.CreateObject("ADODB.recordset")<br />sql="SELECT * FROM WebFinErr"<br />rs.Open sql, conn<br />%><br /><br /><table border="0" width="100%"><br /><tr><br /><%for each x in rs.Fields<br /> response.write("<th>" & x.name & "</th>")<br />next%><br /></tr><br /><%do until rs.EOF%><br /> <tr><br /> <%for each x in rs.Fields%><br /> <td><%Response.Write(x.value)%></td><br /> <%next<br /> rs.MoveNext%><br /> </tr><br /><%loop<br />rs.close<br />conn.close<br />%><br /><br />I want the 5th column record with it's header to display below the first 4 column records and headers then to loop through the table displaying similarly. An example is as below:<br /><br />col1header col2header col3header col4header<br />col1record col2record col3record col4record<br />col5header<br />col5record<br />col1header col2header col3header col4header<br />col1record col2record col3record col4record<br />col5header<br />col5record<br />col1header col2header col3header col4header<br />col1record col2record col3record col4record<br />col5header<br />col5record<br />and so on.....<br /><br />Any help from anyone would make a friend for life!!<br />

Reply With Quote
  #2  
Old June 21st, 2001, 06:26 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,578 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
<i><b>Originally posted by : B. Prasad Reddy (b_prasadreddy@yahoo.com)</b></i><br />Dear friend,<br /><br /> As far I know, this is the solution for formatting the table just it needs a small conditions inside. Read this code below and see if this suits you.<br /><br /><%@language=vbscript%><br /><!-- #include virtual="adovbs.inc" --><br /><%<br /> dim rstest,contest,i,fld<br /> <br /> set contest=Server.CreateObject("ADODB.Connection")<br /> contest.Open"Provider=sqloledb;Server=(local);Database=pubs;uid =sa;pwd="<br /> set rstest=Server.CreateObject("ADODB.Recordset")<br /> 'set rstest=contest.Execute("select * from stores")<br /> rstest.Open "select * from stores",contest,adOpenStatic<br />if not rstest.EOF then<br /><br /> Response.write"<table cellpadding=1 cellspacing=1><tr bgcolor=orange>"<br /> 'set the column header expect for the last field in the table<br /> for j=0 to rstest.Fields.Count - 2<br /> Response.write"<th>" & rstest.fields(j).Name & "</th>"<br /> next<br /> Response.write"</tr>"<br /> do while not rstest.EOF<br /> Response.write"<tr bgcolor=cyan>"<br /> for each fld in rstest.Fields<br /> 'Check whether the the field name is not equal to the last field in the table<br /> if fld.Name<> rstest(rstest.fields.Count-1).Name then<br /> Response.write"<td>" &fld.Value & "</td>"<br /> else<br /> Response.write"</tr><tr bgcolor=cyan>"<br /> 'create blank cell for all the cells in the table except for last cell 'for inserting last field name<br /> for j=0 to rstest.Fields.Count-3<br /> Response.write "<th> </th>"<br /> next<br /> Response.write"<th>" & fld.Name &"</th></tr><tr bgcolor=cyan>"<br /> 'Now similarly create blank cells for all the cells except for the last <br /> 'cell which contains last field value<br /> for j=0 to rstest.Fields.Count-3<br /> Response.write "<td> </td>"<br /> next<br /> Response.write"<td>" & fld.Value & "</td>"<br /> 'Don't close the row here as it is the last field it will be closed at 'the end of the for loop<br /> end if<br /> next<br /> Response.write "</tr>"<br /> rstest.MoveNext<br /> loop<br /> 'Close the table here<br /> 'Close the recordset and connection object<br /> Response.write "</table>"<br /> End iF<br /> rstest.Close<br /> set rstest=nothing<br /> contest.Close<br /> set contest=nothing<br /> %>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > asp table formatting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway