Forum Moderators: open

Message Too Old, No Replies

How can I display numbers like this?

         

ajifri

2:20 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



Hi,
I have a MS access database which include one table this table include one field.
I have numbers from 1 to 6 in the fileds and I want to display it in a table like this :

1 2 3
4 5 6

is this possible?

ajifri

10:36 am on Sep 26, 2003 (gmt 0)

10+ Year Member



No reply till now!? :(

richardb

11:34 am on Sep 26, 2003 (gmt 0)

10+ Year Member



Yes, from the example given, you appear to answered your own question!

Might help if you gave the scenario that you are going to apply it to…

ajifri

1:51 pm on Sep 26, 2003 (gmt 0)

10+ Year Member



thanks for your reply
here is my code and only I got three items per raw and I want to get three items for two raws not one.

<tr>
<%
' Write out the records contained in this page
Dim i
For i=1 To pagesize
If Not rs.EOF Then
%>

<td align="center"><img border="0" src="images/products/<%=rs("Product_Image")%>" width="100" height="158" style="border-style: dotted; border-width: 3"><br>
<font face="Tahoma" size="2"><%=rs("Product_Name")%></font>
</br>
<a href="<%=rs("Sound")%>"><font face="Tahoma" size="2">click here to listen</font></a>
<%
rs.MoveNext
END IF
NEXT
%>
</tr>

thanks in advance

mattglet

2:04 pm on Sep 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you need to set a counter. your code will not just magically step down a row when it gets to 3. when your counter gets to 3, you need to insert a </tr> tag, then a <tr> tag, to start a new row.

-Matt

ajifri

7:55 pm on Sep 26, 2003 (gmt 0)

10+ Year Member



do you have any simple example?

duckhunter

9:00 pm on Sep 26, 2003 (gmt 0)

10+ Year Member



Just need to rearrange the HTML you are dumping inside the loop in your example above. Use a table for the items to organize and make each loop of the RS a new <TD> and on your magic number (in this case 3) write out a </TR><TR> like this:

<tr>
<%
' Write out the records contained in this page
Dim y
Response.write "<TD><TABLE><TR>"
If Not rs.EOF Then
Do While Not rs.EOF
%>
<td align="center"><img border="0" src="images/products/<%=rs("Product_Image")%>" width="100" height="158" style="border-style: dotted; border-width: 3"><br>
<font face="Tahoma" size="2"><%=rs("Product_Name")%></font>
</br>
<a href="<%=rs("Sound")%>"><font face="Tahoma" size="2">click here to listen</font></a>
</td>
<%
y = y + 1
If y = 3 then
Response.write "</TR><TR>"
End IF
rs.MoveNext
Loop
'Now close out the last row and then the table and td
Response.write "</TR></TABLE></TD>"
END IF
%>
</tr>

'Note: This is not a very "smart" loop. If you had 9 or say an even number like 10 you might want to get a little fancier with how to determine when/where to break as well as how many columns there are going to be. That too could be dynamic

davegerard

4:37 am on Sep 27, 2003 (gmt 0)

10+ Year Member



How about this?

<html>

<head>
<title></title>
</head>

<body>
<%
db = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=whatever.mdb"

set rs = server.createobject("adodb.recordset")
sql = "select * from table"
rs.open sql, db
if not rs.eof then
%>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
Count = Count + 1
%>
<tr>
<td><font face="Tahoma" size="2"><%if not rs.eof then%><%=rs("Field1")%><%rs.movenext%><%end if%></font></td>
<td><font face="Tahoma" size="2"><%if not rs.eof then%><%=rs("Field1")%><%rs.movenext%><%end if%></font></td>
<td><font face="Tahoma" size="2"><%if not rs.eof then%><%=rs("Field1")%><%rs.movenext%><%end if%></font></td>
</tr>
<%
loop
%>
</table>
<%
end if
rs.close
set rs = nothing
%>
</body>

</html>