www.webdeveloper.com
Results 1 to 9 of 9

Thread: Looking for a way to call a file without having a database

  1. #1
    Join Date
    Feb 2006
    Location
    Pennsylvania
    Posts
    153

    Looking for a way to call a file without having a database

    I'm looking for a way for a user to get a specific pdf file by selecting three options from a group of choices (radio buttons maybe) on a web page without having a database.

    Any ideas?
    A picture is worth a thousand words, but it uses up three thousand times the memory.

  2. #2
    Join Date
    Mar 2011
    Posts
    1,139
    It's certainly possible to do what you want, but you haven't given enough information about how the PDF file would be selected. Can you give us an example of the options you have in mind and how they affect the selection of the PDF?
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Feb 2006
    Location
    Pennsylvania
    Posts
    153
    Basically they would first select an industry. That would then give them the ability to select from a group of cameras and displays we build for that industry. Next they would choose the camera, display and controller they want to use form the available options. Once they have selected the three options they would get a PDF of that systems specs.

    With that they could possibly choose from 3 display models, 6 camera models, and 3 controller models.

    Does this offer enough information?

    Thanks
    A picture is worth a thousand words, but it uses up three thousand times the memory.

  4. #4
    Join Date
    Mar 2012
    Posts
    1,500
    To download a pdf file, dependent upon the three selections, you need to set up an array to link the options to the PDF file name. The logic can be written in PHP (which I prefer) or JavaScript.
    Last edited by jedaisoul; 04-30-2014 at 04:23 AM.

  5. #5
    Join Date
    Mar 2011
    Posts
    1,139
    Well, yes and no. I was focusing on the number '3' from your initial post and didn't expect there to be quite so many possible choices involved. From your explanation here, there would be (at least?) 54 possible combinations. That's going to take a bit of effort.

    What I should have explained is that some software will be required. You could certainly use something like a PHP script on the server to handle it, but I'd probably be inclined to embed some JavaScript in the page to do this unless there's some concern about keeping the location of the PDF files from being disclosed. Essentially, it requires a script that can match the selected options with a particular file. Your situation is a bit too complex to provide an off-the-cuff solution in my spare time here that you could easily adapt to your needs. Maybe someone else will chime in. Good luck!
    Rick Trethewey
    Rainbo Design

  6. #6
    Join Date
    Mar 2012
    Posts
    1,500
    it seems to me that the list of files could be greater than Rick estimates, because there are 54 combinations per industry, and an unspecified number of industries. Still, if once written the number of overall PDF files remains reasonably static, this could still be dealt with in an array without the added complexity of a database. However, the larger the array, the more I would opt for a server-side solution.

    Also PHP offers an alternative to having to amend the code every time a new PDF file is added, or an old one deleted (or even just a change to the title!). That is of storing the options in a CSV file, and dynamically creating the array. Then maintenance of the list of PDF files would be segregated from the maintenance of the code. You also have the option to maintain a list per industry, if appropriate. Assuming a list per industry, the CSV file could be something like:

    Code:
    camera,display,controller,product_code,filename,title,description
    cam1,disp1,cont1,p111,p111.pdf,title,blah blah blah...
    cam1,disp1,cont2,p112,p112.pdf,title,blah blah blah...
    cam1,disp1,cont3,p112,p113.pdf,title,blah blah blah...
    cam1,disp2,cont1,p121,p121.pdf,title,blah blah blah...
    cam1,disp2,cont2,p122,p122.pdf,title,blah blah blah...
    etc...
    Note: One issue with CSV files is that spurious commas can blow the building of the array. That is why the text description (if included) is put at the end of the line. If it happens to contain commas, they merely truncate the description, and the remainder of the line is ignored.
    Last edited by jedaisoul; 04-30-2014 at 05:03 AM.

  7. #7
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    1,843
    there are pitfalls to using CSV, but there are work-arounds for those (using ";" as a delimiter, encapsulating strings with "", escaping delimiters in strings, etc.). XML is a often overlooked format for storing data. JavaScript can parse XML. You also have JSON format, JavaScript can parse this as well. Both are good transport methods. JSON is more loosely defined in comparison to XML. Depending on your needs either XML or JSON should work well.

  8. #8
    Join Date
    Feb 2014
    Location
    Canada
    Posts
    155
    You're going to have at least 54 combinations, so if you're not open to a database, then I'd probably go for XML. Since it should be fairly straight-forward in that it's only reading (unless you're going to be adding files and they won't be static), then you could use PHP's simple_xml set of functions. A CSV can work just as well, however, I would use an uncommon delimiter, such as || just so any punctuation, ' ' or " " don't ruin it.

  9. #9
    Join Date
    Nov 2013
    Posts
    36
    You can do it. But you haven't mention about everything. Although download a PDF file is actually depends on three section. You have to learn about it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles