PDA

View Full Version : need help with asp script


gcapp
08-19-2003, 09:08 PM
Can someone help???

I have been working on an ASP script for days now and can't get some of the finer details correct and I hoped that someone could give me the code.

What I have is a table that has Sale Items listed in it and one of the fields is category. The script I am writing (or trying to) should display all the sale items on a page grouped by category. Now the way I want the images displayed is in a table with 3 images per row. So say I have 6 images for camping, then 3 rows or 3 images would appear and then would be separated by a line for the next group of items. I have written code for this but can't get it right. I can make it where the images will appear in cells, but I can't get a few things down:

1) how to I write the code so the max number o fimages per row is 3??

2) and where do I put code to separate each category of items by a line?

I have attached the code i have written. If anyone can help at all, I would appreciate it.

Gary

allida77
08-19-2003, 10:43 PM
To get only 3 items per row you can use the Mod() function.


<table>
<tr>
<%
iRowCnt = 0
While Not rs.EOF
Response.Write("<td>" & rs(0) & "</td>")
If irowCount Mod 3 = 0 Then
Response.Write("</tr>"<tr>")
End If
rs.MoveNext
iRowCnt = iRowCnt + 1
Wend
%>

</tr>
</table>



For your second question I really cant think of anything off hand. I would think you would need to put an order by in your sql. Then when you get through looping a category response.write("</table><table>") and write out a new table. You would have a table for each category. If you find this many table cumersome then you could create a css class that adds a border-top.

gcapp
08-20-2003, 02:18 PM
I appreciate you sending me the code for the Mod, but I'm not sure where to place it in terms of the attached file. Does it "plug-in" somewhere or do I have to substitute the code you sent for some of the code I have??

I've tried to place it in the code I have, but it doesn't work right or i'm putting it in the wrong place. I'm kind of a novice, so I appoligize.

Gary