SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Manchester
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Turning date into an integer

    I am looking at doing a rotating image using the date to count it up. I have found a small bit of script to do it but have to admit I don't understand what it does and it's not working, can someone look at it please.

    The asp is

    Code:
    <% 
    startofdeployment = cdate("07/08/2005")
    daysrunning = DateDiff("d", startofdeployment, now()) 
    iuserid = 1 + int(daysrunning)
    getRotateImage(iuserid)
    %>
    and the database function is

    Code:
    Sub GetRotateImage(iuserid)
    	set rsRotateImage=conn.execute("SELECT * FROM products where id = '" & iuserid & "'")
    End Sub
    Could someone just have a look at it and tell me whats wrong?

    Thanks

  2. #2
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well it doesn't look complete. Here's is what you are doing:

    This line is setting the variable startofdeployment to the date of 07/08/2005
    Code:
    startofdeployment = cdate("07/08/2005")
    then you are setting the variable daysrunning to the number of days difference between 07/08/2005 and todays date
    Code:
    daysrunning = DateDiff("d", startofdeployment, now())
    Here you are adding 1 to the variable daysrunning and placing the new value in iuserid. Then you are sending that integer to the subroutine getrotateimage
    Code:
    iuserid = 1 + int(daysrunning)
    getRotateImage(iuserid)

    This sub pulls the record from your products table that matches the value in iuserid
    Code:
    Sub GetRotateImage(iuserid)
    set rsRotateImage=conn.execute("SELECT * FROM products where id = '" & iuserid & "'") End Sub

    After that it stops. You are not display any of the data pulled from the products table.

    What exactly do you want to display here?

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Manchester
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well hopefully the output from all the above is a number so I get the record for that ID and display the image with..

    Code:
    <IMG SRC="/images/products/<% = rsRotateImage("keyword1")%>/<% = rsRotateImage("image")%>.jpg"
    but I am getting an EOF error so preume there is something wrong with the integer it's producing?? Do you think the same or am I doing something else wrong?

    How can i display the integer returned to check it's correct and if it is why isn't it pulling the right record?

  4. #4
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can display the ID before you call your sub like this:


    Code:
    startofdeployment = cdate("07/08/2005")
    daysrunning = DateDiff("d", startofdeployment, now()) 
    iuserid = 1 + int(daysrunning)
     
    response.write iuserid
    response.end
    
    getRotateImage(iuserid)
    This will display the variable iuserid and stop the rest of the code from processing so you can see the result.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •