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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disappearing Records ?

Status
Not open for further replies.

mazdaman

Programmer
Oct 17, 2003
55
GB
Ref:
Please go to the above link to see problem. I have a problem with the final record, in the record set, displaying the detail text under the picture.It only seems to happen when there are not two records displaying next to each other.When you click on the image the details are displayed in the right hand side of the page in an IFRAME.
Here is the code I used ...

<% CONST COL_COUNT = 2
If Not abc.EOF Then abc.MoveFirst
col_ctr = 0 'not really necessary
sec_row = ""

Response.Write "<table width=300><tr><th colspan=""" & COL_COUNT & """></th></tr>"
Do Until abc.EOF
If col_ctr mod COL_COUNT = 0 Then
Response.Write "<tr>"
sec_row = "<tr>"
End If

Response.Write "<td align=center width=145 class=imageframe ><a target=frame href='dracaena_detail.asp?pic=" & abc("pic") & "'><img border=0 src='../upload/thumbs/" 'this is where border=0 should go but can not get my head around the syntax

If Trim(abc.Fields.Item("pic").Value) = "" Then
Response.Write "../upload/thumbs/image_1.jpg"

Else Response.Write abc.Fields.Item("pic").Value
End If

Response.Write "'></td>"
sec_row = sec_row & "<td class=greendata >" & abc("name") & "</td>"
If col_ctr mod COL_COUNT = COL_COUNT - 1 Then
Response.Write "</tr>"
Response.Write sec_row & "</tr>"
'Response.Write third_row & "</tr>"
Response.Write "<tr><td>&nbsp;</td></tr>" 'blank row could format this
End If

'used to be: col_cnt = col_cnt + 1
col_ctr = col_ctr + 1
abc.MoveNext
Loop
Response.Write "</table>"%>

Any ideas anybody ? Thanks !
 
Hmm, I seem to find this code vaguelly familiar...

The problem is that your only writing your second row value when you finish outputting the second column, What you need to do is add a check after the loop to see if you only outputted one column and, if so, output an end row, output the secrow variable, then end your table. Something like
Code:
...

   Response.Write "'></td>"
  sec_row = sec_row & "<td class=greendata >" & abc("name") & "</td>"
 If col_ctr mod COL_COUNT = COL_COUNT - 1 Then
      [highlight]'Response.Write "</tr>" this is unnecessary because the tr was already added to the sec_row string[/highlight]
      Response.Write sec_row & "</tr>"
      'Response.Write third_row & "</tr>"
      Response.Write "<tr><td>&nbsp;</td></tr>" 'blank row could format this
   End If

   'used to be: col_cnt = col_cnt + 1
   col_ctr = col_ctr + 1
   abc.MoveNext
Loop

'if we were on the last row col_ctr will be incremented and would mod to 0
'   if it is anything but 0 we still have some info to output
If col_ctr mod COL_COUNT > 0 Then
   'finish outstanding row, output sec_row and finish tat row also
   Response.Write "</tr>" & sec_row & "</tr>"
Response.Write "</table>"
%>

I noticed mid-code that you had an unnecessary <tr> before you output the sec_row variable in the loop. Since your starting tatstring with <tr> each time you start a new second row you don't need to also output an additional <tr> before printing it.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
Help, the rampaging, spear-waving, rabid network gnomes are after me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top