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.
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?
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?
Last edited by jedaisoul; 04-30-2014 at 04:23 AM.
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.
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:
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.
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...
Last edited by jedaisoul; 04-30-2014 at 05:03 AM.
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.
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.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)