//flex table opened by JP

Click to See Complete Forum and Search --> : HTML / Programming Question


Variable
03-24-2001, 05:50 AM
How can I set up a table in a webpage (.asp) so that the first line reads 1. xyz the next line 2. xyz and the next 3. xyz and so on?
I already programmed everything else in there so it gets the text out of a database. But it won't be sorted by ID but by something else (so using the ID as number is out of Question).

I hope you all understood what I wanted?

It should look like that:
1. GetTextfromDB
2. GetTextfromDB
3. GetTextfromDB
4. GetTextfromDB

Now I want tose number to be inserted automatically.

Variable
03-24-2001, 07:54 AM
Here the html-code of that section:

<TABLE cellSpacing=0 cellPadding=0 width=150 bgColor=#ffffff border=0>

<% while ((Repeat2__numRows-- != 0) && (!Recordset1.EOF)) { %>

<TR class=ltgrey>
<TD height=15 width=20>01.</TD> That is where I want to have the numbers
<TD width=110><%=(Charts.Fields.Item("Name").Value)%></TD>
<TD width=25>[<A href=<%=(Charts.Fields.Item("URL").Value)%>><i>Link</i></A>]</TD>
</TR>

<% Repeat2__index++; Recordset1.MoveNext();}%>

</TABLE>

Cool°
Variable

[This message has been edited by Variable (edited 03-24-2001).]

Variable
03-24-2001, 08:44 AM
Come on this is important...

Variable
03-24-2001, 10:25 AM
Sad... it seems nobody knows this.

golfcart
03-24-2001, 10:54 AM
What kind of database are you using?

Variable
03-24-2001, 01:00 PM
Access.
But I can't use the ID because they are ordere by something else not by ID.
I could set up a table with all the numbers but that would not be very smart.

Variable
03-24-2001, 02:50 PM
This is unbelievable!
I posted this in 3 boards and got NO 0 ZERO replies!

Joel Kleppinger
03-24-2001, 02:55 PM
Ok, I don't know ASP (I could tell you how to do it in PHP if you want http://www.sysopt.com/forum/smile.gif ), but the fix should be VERY easy.

Simply have another variable... let's say COUNT. Initialize COUNT = 0 when going into the loop, then incorporate this sort of syntax into the loop header:

while ( .... , COUNT++)

then where you want the number to be set, you just have the variable COUNT there, with a period and a space after it.

That should do it. If you want some other solution or that doesn't work in ASP, then I dunno.

Joel Kleppinger
03-24-2001, 02:58 PM
Oh wait... I think that's bad logic (thinking of a for loop)

in your while loop, increment count, but you only want to put it in the loop declaration if you only want to return a specific number of rows (in that case COUNT++ < NUMROWS).

Variable
03-24-2001, 03:22 PM
That should work somehow.

How would you do it in PHP?
I don't really care how it is done....

I do everything using Dreamweaver UltraDev and to be honest I don't know very much about programming...

I tried what you said but I couldn't get it to work.

Variable
03-24-2001, 03:27 PM
I defined it at the beginning of the page with the others (that should be fine):

var Count = 0;

Then I added the following:


<TABLE cellSpacing=0 cellPadding=0 width=150 bgColor=#ffffff border=0>
<% while ((Repeat2__numRows-- != 0) && (!Charts.EOF)) { %>

<% Count++ %>

<TR>
<TD height=15 width=20><%=(Count.Value) %>.</TD>

....


I tried different variations but somehow the Count-Value isn't displayed.

golfcart
03-25-2001, 12:14 AM
Not quite sure if this will help or not, but heres some generic access db code. replace
name_of_dsn, name_of_access_table, column_you_choose, and whatever_you_want with the apropriate names.


<%
Dim objConn, objRS

Set objConn = Server.CreateObject("ADODB.Connection")

objConn.Open "DSN=name_of_dsn;"

Set objRS = objConn.Execute("SELECT * FROM name_of_access_table WHERE column_you_choose = '" & whatever_you_want & "'")

do while not objRS.eof

column_1 = objRS(0)
column_2 = objRS(1)
column_3 = objRS(2)
column_4 = objRS(3)
column_5 = objRS(4)
column_6 = objRS(5)
%>
<table>
<tr>
<td>
<%=objRS(0)%>
</td>
</tr>
</table>

Variable
03-25-2001, 02:20 AM
Yeah, guys I finally got it right:
I defined the variable at the beginning with the others:

var COUNT = 0;


Then I modified the important part:


<TABLE>

<% while ((Repeat2__numRows-- != 0) && (!Charts.EOF)) { %>

<% Count = Count + 1 %>

<TR><TD>
<%=Count%>.
</TD>

<TD>
blablabla the rest of the database Query
<TD>

</TR>
<%
Repeat2__index++;
Charts.MoveNext();
}
%>

</TABLE>