Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

ASP logic question

  • 20-03-2003 11:39am
    #1
    Subscribers Posts: 4,419 ✭✭✭


    Hello.

    I have a database table (Access) that contains 9 different fields for image names. At the moment, any single record could contain no references or it could have 9 different ones.
    The ones that have names in them at the moment have something like image.jpg in there...

    What I want to do is this:
    If there is a record in the field, replace .jpg with _tn.jpg and display the thumbnail version of that image (this I can do easily).
    My problem is how to tackle those records that are empty.
    Should I have a default "no image" reference in the database itself? Or maybe use an IF/THEN thing to check if its empty first?

    I am an amateur at this so I would just like a pointer towards the best method of tackling this and then I'll give it a go...

    Thanks,
    Mark.


Comments

  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    If Not IsNull(fieldValue) Then
    'Do image display code
    Else
    'Do something else, or maybe nothing.
    End If.

    Is there a strong reason for having a limit of 9, or is that just a matter of "probably won't need more than 9". In the latter case you may be better of restructuring the database to allow any number of images to any field (using another table and a many-1 relationship).


  • Subscribers Posts: 4,419 ✭✭✭PhilipMarlowe


    Thanks for the reply.

    Its a database of plants that we have for labelling software that I want to use for our website. I haven’t modified the structure of the database.

    Any plant wouldn’t be likely to have more than 9 separate images…. E.g there are approx 7000 records (plants) in the database but maybe 1500 images in total. Mostly any plant that has an image associated with it would have 1 or 2 images, and odd few would have more.
    That is kinda why I was wondering if it was pointless to check for Null on these or if there was a more sensible way of tackling this.

    At the moment, I have a search page which brings up a results page with limited detail and then a link to a detail page which would have these images. My intention is to display the thumbnails where they exist and then link these to the full size version which is why I am doing the replace function in the first place.


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Have an images table that looks something like:
    CREATE TABLE images (
    	imageID int IDENTITY (1, 1) NOT NULL,
    	plantID int NOT NULL,
    	filename varchar(50) NOT NULL
    )
    

    Then when you are dealing with a given plant you can
    SELECT filename FROM images WHERE plantID = @plantID
    

    That will give you are recordset you can loop through to get all of the image filenames for that plant. You no longer take up any space for the plants with no image files, and should there be a plant with more than 9 images (because someone went overboard with the digital camera :) ) then it will support that as well.

    It's also more efficient to loop through an empty recordset (you just test it once and then jump past all the code for dealing with the images) than it is to test each of 9 fields.

    Most importantly this system more closely models what you are trying to model.


Advertisement