2 column display - HELP SQL/ASP

2 column display - HELP SQL/ASP

am 17.11.2004 03:53:22 von SusieQ

I posted this over in the SQL forum, but I think it was the wrong place. My
apologies.

SQL2K - I have a list that can be printed out in one column of company names
and addresses, but they would like to have this in 2 column format. They
don't want me to rewrite anything, just add a column.

IE: company 1 company2
Addr Addr
etc

I'm stumped. I am having trouble with the former programmers code. It's
not documented at all. Here is the page. Normally I would have a recordset
and do a recordset.movenext & loop, but this isn't done that way.
Here is the location of the page:
http://www.happyfacerewards.com/printmerchantcond.asp
Scrolling down you will see where I have added the comment for the first
column and then the second
Can anyone help me with this? I'd be grateful for anything I could get.
Thanks so much in advance
------------------------------------------------------------ ---------------------------------------------



<%
'on error resume next

Dim strSql
Dim allStores, numOfStore
Dim lastHeader
Dim typeArray,styleArray,categoryList
Dim today
today=date()

strSql="SELECT tblStores.storeId, tblStores.storeName,
tblStores.storeAddresse, tblStores.storeCity, tblProvinces.sName,
tblCountries.cName, tblStores.storePCode, tblCategory.categoryName,
tblStyle.styleName, tblType.typeName, tblOffers.offerId,
tblOffers.offerName, tblStores.storePhone, tblStores.storeFax,
tblStores.storeEmail, tblStores.storeWebsite, tblMerchant.merchantCode " _
& "FROM tblMerchant INNER JOIN (tblCategory INNER JOIN ((tblCountries INNER
JOIN tblProvinces ON tblCountries.cId = tblProvinces.sCountryId) INNER JOIN
((tblType INNER JOIN (tblStyle INNER JOIN tblStores ON tblStyle.styleId =
tblStores.storeStyleId) ON tblType.typeId = tblStores.storeTypeId) INNER
JOIN tblOffers ON tblStores.storeId = tblOffers.offerStoreId) ON
tblProvinces.sId = tblStores.storeProvinceId) ON (tblCategory.categoryId =
tblStores.storeCategoryId) AND (tblCategory.categoryId =
tblStyle.styleCategoryId) AND (tblCategory.categoryId =
tblType.typeCategoryId)) ON tblMerchant.merchantId =
tblStores.storeMerchantId " _
& "WHERE tblMerchant.merchantStatusId=2 ORDER BY
tblStores.storeCity,tblStores.storeName ASC"

Call openDB()
Set rs=conn.execute(strSql)
If rs.eof Then
allStores=Array("Null")
numOfStore=-1
Else
allStores=rs.getRows()
numOfStore=Ubound(allStores,2)
End If

categoryList=allCategory
typeArray=arrayOfTypes
styleArray=arrayOfStyles
Call closeDB()
%>


Happy Face Rewards








cellspacing=0 valign=top>


---------------- HERE IS THE HEADING WHICH GIVES THE
CITY ---------------------

<%
If numOfStore >-1 Then
For x=0 To numOfStore
If lastHeader <> allStores(3,x) Then
Response.Write ""
lastHeader=allStores(3,x)
End If

---------------- HERE IS THE FIRST COLUMN WHICH WORKS ---------------------
Response.Write ""
Response.Write ""
Response.Write ""
Response.Write ""
Response.Write ""
Else
Response.Write ""
End If

Else
Response.Write ""%>



<%
End If
Next
Else
Response.Write " height=290 align=center>Your search criteria resulted
in 0 matches, please adjust and try again




Merchants as of:
class="formText">http://www.happyfacerewards.com

class=SectionTitlePrint>" & allStores(3,x) & "
class=offertext>" & allStores(1,x) &"
"
Response.Write ""& allStores(2,x)& "  "&
allStores(12,x) & "  "& allStores(13,x) &"
" &
allStores(11,x) & "

"
For y = x+1 To numOfStore
If allStores(0,x) = allStores(0,y) Then
Response.Write "" & allStores(11,y) &
"

"
x=y
Else
Exit For
End If
Next
---------------- THIS IS THE SECOND COLUMN I ADDED, BUT IT JUST DUPLICATES
THE FIRST ---------------------

Response.Write "
class=offertext>" & allStores(1,x) &"
"
Response.Write ""& allStores(2,x)& "  "&
allStores(12,x) & "  "& allStores(13,x) &"
" &
allStores(11,x) & "

"
For y = x+1 To numOfStore
If allStores(0,x) = allStores(0,y) Then
Response.Write "" & allStores(11,y) &
"

"
x=y
Else
Exit For
End If
Next

---------------- IF THERE ARE NO MORE STORES, THEN IT
ENDS ---------------------

If (x <> numOfStore) Then
If allStores(3,x) <> allStores(3,x+1) Then
Response.Write "


Happy Face Rewards
A Division of
International Fun Card Inc

Box 261 106 - 1656 Martin Drive
White Rock, B.C. V4A 6E7 Canada


 
"
End If
%>





Re: 2 column display - HELP SQL/ASP

am 17.11.2004 13:55:32 von jeff.nospam

On Tue, 16 Nov 2004 18:53:22 -0800, "SusieQ" wrote:

>I posted this over in the SQL forum, but I think it was the wrong place. My
>apologies.

It's not really ASP either, it's a matter of client-side formatting,
in your case HTML tables.

You might look at a cleaner sample of the GetRows method to see what
you're facing:

http://www.asp101.com/samples/viewasp.asp?file=db%5Fgetrows% 2Easp

Then it's a simple matter of setting your loop to not end the row in
the table until it's pulled the second row into the next column(s).

Jeff

>SQL2K - I have a list that can be printed out in one column of company names
>and addresses, but they would like to have this in 2 column format. They
>don't want me to rewrite anything, just add a column.
>
>IE: company 1 company2
> Addr Addr
>etc
>
>I'm stumped. I am having trouble with the former programmers code. It's
>not documented at all. Here is the page. Normally I would have a recordset
>and do a recordset.movenext & loop, but this isn't done that way.
>Here is the location of the page:
>http://www.happyfacerewards.com/printmerchantcond.asp
>Scrolling down you will see where I have added the comment for the first
>column and then the second
>Can anyone help me with this? I'd be grateful for anything I could get.
>Thanks so much in advance
>----------------------------------------------------------- ----------------------------------------------
>
>
>
><%
>'on error resume next
>
>Dim strSql
>Dim allStores, numOfStore
>Dim lastHeader
>Dim typeArray,styleArray,categoryList
>Dim today
>today=date()
>
>strSql="SELECT tblStores.storeId, tblStores.storeName,
>tblStores.storeAddresse, tblStores.storeCity, tblProvinces.sName,
>tblCountries.cName, tblStores.storePCode, tblCategory.categoryName,
>tblStyle.styleName, tblType.typeName, tblOffers.offerId,
>tblOffers.offerName, tblStores.storePhone, tblStores.storeFax,
>tblStores.storeEmail, tblStores.storeWebsite, tblMerchant.merchantCode " _
>& "FROM tblMerchant INNER JOIN (tblCategory INNER JOIN ((tblCountries INNER
>JOIN tblProvinces ON tblCountries.cId = tblProvinces.sCountryId) INNER JOIN
>((tblType INNER JOIN (tblStyle INNER JOIN tblStores ON tblStyle.styleId =
>tblStores.storeStyleId) ON tblType.typeId = tblStores.storeTypeId) INNER
>JOIN tblOffers ON tblStores.storeId = tblOffers.offerStoreId) ON
>tblProvinces.sId = tblStores.storeProvinceId) ON (tblCategory.categoryId =
>tblStores.storeCategoryId) AND (tblCategory.categoryId =
>tblStyle.styleCategoryId) AND (tblCategory.categoryId =
>tblType.typeCategoryId)) ON tblMerchant.merchantId =
>tblStores.storeMerchantId " _
>& "WHERE tblMerchant.merchantStatusId=2 ORDER BY
>tblStores.storeCity,tblStores.storeName ASC"
>
>Call openDB()
> Set rs=conn.execute(strSql)
> If rs.eof Then
> allStores=Array("Null")
> numOfStore=-1
> Else
> allStores=rs.getRows()
> numOfStore=Ubound(allStores,2)
> End If
>
> categoryList=allCategory
> typeArray=arrayOfTypes
> styleArray=arrayOfStyles
>Call closeDB()
>%>
>
>
>Happy Face Rewards
>
>
>
>
>
>
>
>


> >cellspacing=0 valign=top>
>
>
>---------------- HERE IS THE HEADING WHICH GIVES THE
>CITY ---------------------
>
> <%
> If numOfStore >-1 Then
> For x=0 To numOfStore
> If lastHeader <> allStores(3,x) Then
> Response.Write ""
> lastHeader=allStores(3,x)
> End If
>
>---------------- HERE IS THE FIRST COLUMN WHICH WORKS ---------------------
> Response.Write ""
> Response.Write ""
> Response.Write ""
> Response.Write ""
> Response.Write ""
> Else
> Response.Write ""
> End If
>
> Else
> Response.Write ""%>
>
>
>
> <%
> End If
> Next
> Else
> Response.Write " >height=290 align=center>Your search criteria resulted
>in 0 matches, please adjust and try again

>
>
>
>
Merchants as of:
>
>class="formText">http://www.happyfacerewards.com

>class=SectionTitlePrint>" & allStores(3,x) & "
>class=offertext>" & allStores(1,x) &"
"
> Response.Write ""& allStores(2,x)& "  "&
>allStores(12,x) & "  "& allStores(13,x) &"
" &
>allStores(11,x) & "

"
> For y = x+1 To numOfStore
> If allStores(0,x) = allStores(0,y) Then
> Response.Write "" & allStores(11,y) &
>"

"
> x=y
> Else
> Exit For
> End If
> Next
>---------------- THIS IS THE SECOND COLUMN I ADDED, BUT IT JUST DUPLICATES
>THE FIRST ---------------------
>
> Response.Write "
>class=offertext>" & allStores(1,x) &"
"
> Response.Write ""& allStores(2,x)& "  "&
>allStores(12,x) & "  "& allStores(13,x) &"
" &
>allStores(11,x) & "

"
> For y = x+1 To numOfStore
> If allStores(0,x) = allStores(0,y) Then
> Response.Write "" & allStores(11,y) &
>"

"
> x=y
> Else
> Exit For
> End If
> Next
>
>---------------- IF THERE ARE NO MORE STORES, THEN IT
>ENDS ---------------------
>
> If (x <> numOfStore) Then
> If allStores(3,x) <> allStores(3,x+1) Then
> Response.Write "


>

Happy Face Rewards
A Division of
>International Fun Card Inc

> Box 261 106 - 1656 Martin Drive
White Rock, B.C. V4A 6E7 Canada


>
 
"
> End If
>%>
>
>
>


>
>
>
>
>

Re: 2 column display - HELP SQL/ASP

am 17.11.2004 19:04:32 von SusieQ

Thanks Jeff - this certainly helped me understand what the code is I have.
The question I have now is - I understand the loop part on the TD's, but it
looks like that may only be if I want to output all the fields. I only have
4 fields that I actually want to display, but have selected more than that
because of some testing I have to do.
Can you give me any suggestions on how I might handle it that way?

I loop through the records until there are no more
I check for heading content making sure each time the city changes it rights
a row with the new city
I print out in 2 columns, information on 1 company
I print out in the second column all the specials this company may have
I check the heading field and if it is different start this process over

I can't figure out how to make this loop with an array for the life of me.

If I was using the rs object I'd do this
do while not objRs.EOF
write first 2 columns with data
objRs.MoveNext
if objRs.EOF then exit do
write next 2 columns if more data there
objRs.MoveNext
loop

Can you help with this?



"Jeff Cochran" wrote in message
news:419b473b.1615910897@msnews.microsoft.com...
> On Tue, 16 Nov 2004 18:53:22 -0800, "SusieQ" wrote:
>
>>I posted this over in the SQL forum, but I think it was the wrong place.
>>My
>>apologies.
>
> It's not really ASP either, it's a matter of client-side formatting,
> in your case HTML tables.
>
> You might look at a cleaner sample of the GetRows method to see what
> you're facing:
>
> http://www.asp101.com/samples/viewasp.asp?file=db%5Fgetrows% 2Easp
>
> Then it's a simple matter of setting your loop to not end the row in
> the table until it's pulled the second row into the next column(s).
>
> Jeff
>
>>SQL2K - I have a list that can be printed out in one column of company
>>names
>>and addresses, but they would like to have this in 2 column format. They
>>don't want me to rewrite anything, just add a column.
>>
>>IE: company 1 company2
>> Addr Addr
>>etc
>>
>>I'm stumped. I am having trouble with the former programmers code. It's
>>not documented at all. Here is the page. Normally I would have a
>>recordset
>>and do a recordset.movenext & loop, but this isn't done that way.
>>Here is the location of the page:
>>http://www.happyfacerewards.com/printmerchantcond.asp
>>Scrolling down you will see where I have added the comment for the first
>>column and then the second
>>Can anyone help me with this? I'd be grateful for anything I could get.
>>Thanks so much in advance
>>---------------------------------------------------------- -----------------------------------------------
>>
>>
>>
>><%
>>'on error resume next
>>
>>Dim strSql
>>Dim allStores, numOfStore
>>Dim lastHeader
>>Dim typeArray,styleArray,categoryList
>>Dim today
>>today=date()
>>
>>strSql="SELECT tblStores.storeId, tblStores.storeName,
>>tblStores.storeAddresse, tblStores.storeCity, tblProvinces.sName,
>>tblCountries.cName, tblStores.storePCode, tblCategory.categoryName,
>>tblStyle.styleName, tblType.typeName, tblOffers.offerId,
>>tblOffers.offerName, tblStores.storePhone, tblStores.storeFax,
>>tblStores.storeEmail, tblStores.storeWebsite, tblMerchant.merchantCode " _
>>& "FROM tblMerchant INNER JOIN (tblCategory INNER JOIN ((tblCountries
>>INNER
>>JOIN tblProvinces ON tblCountries.cId = tblProvinces.sCountryId) INNER
>>JOIN
>>((tblType INNER JOIN (tblStyle INNER JOIN tblStores ON tblStyle.styleId =
>>tblStores.storeStyleId) ON tblType.typeId = tblStores.storeTypeId) INNER
>>JOIN tblOffers ON tblStores.storeId = tblOffers.offerStoreId) ON
>>tblProvinces.sId = tblStores.storeProvinceId) ON (tblCategory.categoryId =
>>tblStores.storeCategoryId) AND (tblCategory.categoryId =
>>tblStyle.styleCategoryId) AND (tblCategory.categoryId =
>>tblType.typeCategoryId)) ON tblMerchant.merchantId =
>>tblStores.storeMerchantId " _
>>& "WHERE tblMerchant.merchantStatusId=2 ORDER BY
>>tblStores.storeCity,tblStores.storeName ASC"
>>
>>Call openDB()
>> Set rs=conn.execute(strSql)
>> If rs.eof Then
>> allStores=Array("Null")
>> numOfStore=-1
>> Else
>> allStores=rs.getRows()
>> numOfStore=Ubound(allStores,2)
>> End If
>>
>> categoryList=allCategory
>> typeArray=arrayOfTypes
>> styleArray=arrayOfStyles
>>Call closeDB()
>>%>
>>
>>
>>Happy Face Rewards
>>
>>
>>
>>
>>
>>
>>
>>


>> >>cellspacing=0 valign=top>
>>
>>
>>---------------- HERE IS THE HEADING WHICH GIVES THE
>>CITY ---------------------
>>
>> <%
>> If numOfStore >-1 Then
>> For x=0 To numOfStore
>> If lastHeader <> allStores(3,x) Then
>> Response.Write ""
>> lastHeader=allStores(3,x)
>> End If
>>
>>---------------- HERE IS THE FIRST COLUMN WHICH
>>WORKS ---------------------
>> Response.Write ""
>> Response.Write ""
>> Response.Write ""
>> Response.Write ""
>> Response.Write ""
>> Else
>> Response.Write ""
>> End If
>>
>> Else
>> Response.Write ""%>
>>
>>
>>
>> <%
>> End If
>> Next
>> Else
>> Response.Write " >>height=290 align=center>Your search criteria
>>resulted
>>in 0 matches, please adjust and try again

>>
>>
>>
>>
Merchants as of:
>>
>>class="formText">http://www.happyfacerewards.com

>>class=SectionTitlePrint>" & allStores(3,x) & "
>>class=offertext>" & allStores(1,x) &"
"
>> Response.Write ""& allStores(2,x)& "  "&
>>allStores(12,x) & "  "& allStores(13,x) &"
" &
>>allStores(11,x) & "

"
>> For y = x+1 To numOfStore
>> If allStores(0,x) = allStores(0,y) Then
>> Response.Write "" & allStores(11,y) &
>>"

"
>> x=y
>> Else
>> Exit For
>> End If
>> Next
>>---------------- THIS IS THE SECOND COLUMN I ADDED, BUT IT JUST DUPLICATES
>>THE FIRST ---------------------
>>
>> Response.Write "
>>class=offertext>" & allStores(1,x) &"
"
>> Response.Write ""& allStores(2,x)& "  "&
>>allStores(12,x) & "  "& allStores(13,x) &"
" &
>>allStores(11,x) & "

"
>> For y = x+1 To numOfStore
>> If allStores(0,x) = allStores(0,y) Then
>> Response.Write "" & allStores(11,y) &
>>"

"
>> x=y
>> Else
>> Exit For
>> End If
>> Next
>>
>>---------------- IF THERE ARE NO MORE STORES, THEN IT
>>ENDS ---------------------
>>
>> If (x <> numOfStore) Then
>> If allStores(3,x) <> allStores(3,x+1) Then
>> Response.Write "

>> height=1>

>>

Happy Face Rewards
A Division of
>>International Fun Card Inc

>> Box 261 106 - 1656 Martin Drive
White Rock, B.C. V4A 6E7
>> Canada


>>
>> src="images/key-face4.gif">
 
"
>> End If
>>%>
>>
>>
>>


>>
>>
>>
>>
>>
>