Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting fields to determine number of table columns

Status
Not open for further replies.

ChrisQuick

Programmer
Oct 4, 1999
144
US
We have a page that we want to use to document some of our tables. On the page we want to show the field name, field type and size in the same HTML table row (or &lt;TR&gt; tag). Listing the information this way works fine, but if there are more than 30 fields in the table, we want to display the information for 2 fields on the same row. Example:<br>
<br>
Field1Name, Type, Size<br>
Field2Name, Type, Size<br>
<br>
if less than 30 records.<br>
<br>
But:<br>
Field1Name, Type, Size Field31Name, Type, Size<br>
Field2Name, Type, Size Field32Name, Type, SIze<br>
Field3Name, Type, Size<br>
<br>
if there are 32 fields in the database.<br>
<br>
<br>
Does anyone know how to do this?<br>

 
There are several ways to accomplish this task. I would load an array as I step through the field information. Then determine number of fields and output them to your page (table) based on the count. If under 30 show all collected data and if 30 and over show the two data fields in a two column table.<br>
<br>
Good Luck<br>
<br>

 
Another approach...<br>
Stick the tr in another table - <br>
Then close this table the parent table td and start a new parent table td and a new table <br>
something like below the logic isn't exact but with tweaking should fit task<br>
<br>
'start loop of recordset<br>
dim iRS <br>
dim i<br>
dim iTable2<br>
irs = (rsOptions.RecordCount / 2)<br>
i = 1<br>
do until rsOptions.EOF<br>
iCount = iCount + 1<br>
%&gt;<br>
<br>
&lt;%if icount &lt;= ((irs * i) + 1) then%&gt;<br>
&lt;tr&gt;<br>
&lt;td&gt;<br>
&lt;img src=&quot;./image/orangeball.gif&quot; alt=&quot;show listing for &lt;%=rsOptions.Fields.Item(&quot;Type Name&quot;).Value%&gt;&quot; WIDTH=&quot;15&quot; HEIGHT=&quot;16&quot; border=&quot;0&quot;&gt;<br>
&lt;/td&gt;<br>
&lt;td&gt;<br>
&lt;a href=&quot;./&lt;%=sPageName%&gt;?providertype=&lt;%=rsOptions.Fields.Item(&quot;Provider Type&quot;).Value%&gt;&quot;&gt;&lt;font face=&quot;verdana&quot; size=&quot;1&quot;&gt;&lt;%=rsOptions.Fields.Item(&quot;Type Name&quot;).Value%&gt;&lt;/a&gt;&lt;/font&gt;<br>
&lt;/td&gt;<br>
&lt;/tr&gt;<br>
&lt;%else%&gt; <br>
&lt;%if iTable2 &lt; 1 then%&gt;<br>
&lt;/table&gt;<br>
&lt;/td&gt;<br>
&lt;td align=&quot;left&quot; valign=top&gt;<br>
&lt;table border=0&gt;<br>
&lt;%end if%&gt;<br>
&lt;tr&gt;<br>
&lt;td&gt;<br>
&lt;img src=&quot;./image/orangeball.gif&quot; alt=&quot;show listing for &lt;%=rsOptions.Fields.Item(&quot;Type Name&quot;).Value%&gt;&quot; WIDTH=&quot;15&quot; HEIGHT=&quot;16&quot; border=&quot;0&quot;&gt;<br>
&lt;/td&gt;<br>
&lt;td&gt;<br>
&lt;a href=&quot;./&lt;%=sPageName%&gt;?providertype=&lt;%=rsOptions.Fields.Item(&quot;Provider Type&quot;).Value%&gt;&quot;&gt;&lt;font face=&quot;verdana&quot; size=&quot;1&quot;&gt;&lt;%=rsOptions.Fields.Item(&quot;Type Name&quot;).Value%&gt;&lt;/a&gt;&lt;/font&gt;<br>
&lt;/td&gt;<br>
&lt;/tr&gt;<br>
&lt;%i = i + 1<br>
iTable2 = iTable2 + 1%&gt;<br>
&lt;%end if%&gt;<br>
<br>
&lt;%<br>
rsOptions.MoveNext<br>
loop<br>
%&gt;<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top