Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Displaying Pictures from Database
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Displaying Pictures from Database

 Post Reply Post Reply Page  12>
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: Displaying Pictures from Database
    Posted: 05 August 2003 at 10:56am

I have a products catalog. I would like to be able to display the pictures from a database on a web page. I already know how to do this. However, I would like to be able to display two pictures on the same line. If it happens that there are 5 pictures to show. I would like for the last one to show up without giving me an error message. How would I do this?

Please take a look at http://www.signaturecarpets.com/runninglines.php?type=Cut+Pile to get an idea what I am talking about.

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2003 at 10:59am
It works fine for me, no errors...
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2003 at 11:01am

Mart,

That web page doesn't belong to me. I was just using that page as an example. I would like to be able to do something like that in ASP. Does anyone know how to do this in ASP?

 

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2003 at 11:15am
If you are using a recordset(rs)
<table>
<%
cnt=1
Do while not rs.EOF
if cnt mod 2 = 1 then Response.Write "<tr>" end if
Response.Write "<td>Stuff goes here</td>"
cnt=cnt+1
if cnt mod 2 = 1 then Response.Write "</tr>" end if
rs.MoveNext
Loop
if cnt mod 2 = 0 then Response.Write "</tr>" end idf
%>
</table>
Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2003 at 11:48am

The gallery that I created should be of some help, download the code and take a peek, then you can see how to do it, or just use it.

www.flameservers.com/asp_apps/gallery/

Hope this helps.

- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2003 at 1:32pm

Flamewave, Thank you for your willingness to share your code!

I have the web page up at http://65.174.82.72/specials2.asp. There is an error message on this web page. I only want two pictures to show up on one line. I suspect that the error message is due to me having a third picture. I will copy and paste my code for you. Does anyone know how to this code to make the error message disappear? Please look at the error message on the page. The third picture showed up, but the product's name didn't show up.

Take a look at my code below.

dim rs

dim sqlString

dim connectionString, databaseName, path

dim SpecialsID, ImageName, SpecialsName

'Set connection details (No need to include the code for this)

Const NUM_COLUMNS = 2

Dim EndOfRS

Dim NumRecords, Temp1, Temp2, Temp3, i

EndOfRS = 0

NumRecords = 0

 

'Start sql string with Join

sqlString = "select * from Specials"

'Create a recordset

set rs = Server.CreateObject("ADODB.Recordset")

rs.CursorType = 2

rs.Open sqlString, connectionString

%>

<HTML>

<HEAD>

<TITLE>Specials</TITLE>

<p>

<P>

</HEAD><BODY>

<center><table border="0" width="100%">

<%

Do While Not rs.EOF

NumRecords = NumRecords + 1

rs.MoveNext

Loop

rs.MoveFirst

Do While NOT rs.EOF %>

<tr>

<%

For i=1 to NUM_COLUMNS

%><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="ViewSpecial.asp?qryID=<%=rs("SpecialsID")%>"><img src=../Upload/<%= rs("ImageName") %> width="144" height="144" border="0" alt=<%= rs("SpecialsName")%>></a></td>

<% If rs.EOF Then

EndOfRS = 1

Exit For

End If

rs.MoveNext

Next

If EndOfRS = 0 Then

rs.Move -NUM_COLUMNS

If rs.BOF = True Then

rs.MoveFirst

End If

End If

If EndOfRS = 1 Then

rs.MoveFirst

Temp1 = InStr((NumRecords / NUM_COLUMNS), ".")

Temp2 = Left((NumRecords / NUM_COLUMNS), Temp1-1)

Temp3 = Temp2 * NUM_COLUMNS

rs.Move Temp3

End If

%>

</tr>

<tr>

<%

For i=1 to NUM_COLUMNS

%><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><%= rs("SpecialsName") %></b><p><p><p></td>

<%rs.MoveNext

If rs.EOF Then Exit For

Next

%>

</tr>

<% Loop %>

</center></table>

</body>

</html>

 



Edited by Misty
Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2003 at 6:12pm

Hehe...it looks like you are using an older ASP gallery that I had developed back when I was first learning ASP. The new one that I posted the link to above is much better and performs a bit faster, and it's easier to customize, just FYI.

As far as the error goes, Try changing the two for...next loops to check for eof before any work is done in the loop:

 For i=1 to NUM_COLUMNS
  If rs.EOF Then
   EndOfRS = 1
   Exit For
  End If
%>
     <td>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <a href="ViewSpecial.asp?qryID=<%=rs("SpecialsID")%>"><img src=../Upload/<%= rs("ImageName") %> width="144" height="144" border="0" alt=<%= rs("SpecialsName")%>></a>
     </td>
<%
  rs.MoveNext
 Next

 For i=1 to NUM_COLUMNS
  If rs.EOF Then Exit For
%>
     <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><%= rs("SpecialsName") %></b><p><p><p></td>
<%
  rs.MoveNext
 Next

Hope that helps.

- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 06 August 2003 at 11:30am

Flamewave, Thank you for the help! You helped me to build a web application for cards before. That is where I got the old code from. The new gallery is good. I just didn't want to have pages numbered.

The error message is gone. However, I don't like the space between the pictures. I wish that the pictures were closer. I removed the spaces before the <td> tag. Does anyone know how I might be able to move the pictures closer to each other. You can take a look at http://65.174.82.72/specials2.asp.

 

 

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.