• Misc Help
  • whats the best way to get dynamic table on a webpage?

hi so i have this pdf designed with tables in it that i embed on the website with product list, the problem is, its a pdf, a static document. every time there is a new product, the editor have to insert it alphabetically and re-editing the entire pdf (10+ pages) is annoying.

is there a way i can get a table on web page, have someone edit it without using html/css and have it reflected on the web page? (the person that will be doing the editing have no html/css knowledge)

i looked at Google sheets and excel embed as a solution, but i want more design options than they can offer this is the page on my site

https://bsgcraftbrewing.com/spot-hops

right now, the process of adding a new item on that table would be to bump everything down and that a slot of work

My preferred solution would be to put the data in a database, then either provide an admin front-end in the app where they could edit the data, or perhaps let them export their spreadsheet to a CSV file and upload it to a script that would use it to update the database.

If that's not practical, then my next choice would be to have them edit their spreadsheet and export it as a CSV file, then upload that CSV file. Your PHP app could then read/parse that file via fgetcsv() and output the data in a HTML table.

The way this is normally done is to store the raw data in a database, then query for the data to produce the html for the web page. The styling of the page is determined by the css that's defined in the template being used to produce the web page. The template is populated from the retrieved data. To enter new data or edit existing data, the user only needs to login and interface with a html form.

Does the output need to be a .pdf document that can be downloaded, like the current page is doing? If so, you can do this by dynamically producing a pdf document on the server from the data stored in the database, either only when that data is changed or on each page request.

As a note, by using a .pdf document, that page is not directly searchable in the browser (the browser listed x number of results, but it wasn't scrolling and showing what was expected.) By just outputting the data from the database as html on a web page, a search in the browser would work as expected.

Edit: something I did while viewing the page caused the grey border section above the header/logo in the pdf section to start showing a line of the document while scrolling. This want away after refreshing the page and I cannot duplicate it. So, the current method has some browser/pdf/document bug in it.

Another advantage of just displaying this as a html document is, you can have letter based navigation, so someone can just jump to the section starting with specific variety names. I'm not sure how the section at the very end relates to the rest of the (historical pricing) data, but you can have a specific navigation link to it as well.

The PDF could also be generated dynamically from the content of the database (see also FPDF for an alternative). It depends on how your customers use the document whether staying with PDF is worthwhile or if they're fine with just a web page (possibly with @media CSS for print output).

Constructing the code to dynamically generate the PDF would involve somewhat more work than a web page, of course.

But the database is crucial, since you say you need to separate the task of maintaining the price list from the task of rendering it; the db bridges those tasks. It probably doesn't need the full DBMS treatment; if your editor knows Excel then exporting a bunch of CSV files. Or, using something like PHPSpreadsheet (that's just the first active project on the subject I found in a search, not an endorsement), read the Excel file directly.

Be aware that an Excel>PDF>display process on every request would be significantly slower than just a link to a static document. Most uses of these libraries would be for offline conversion/generation, not real time. So it would be an application the editor would run once when the spreadsheet has been updated, and the PDF (or HTML page) generated and put on the site. At which point I wonder if Excel can be coerced (actually I'm pretty sure it can) into producing a document that looks a lot like what you already have. Because then the editor can just edit the spreadsheet and export the PDF straight from Excel.

Hm...

pbismad As a note, by using a .pdf document, that page is not directly searchable in the browser (the browser listed x number of results, but it wasn't scrolling and showing what was expected.

It was working for me; mind you, I had the page focused on the PDF.

pbismad Another advantage of just displaying this as a html document is, you can have letter based navigation, so someone can just jump to the section starting with specific variety names.

PDFs can also have bookmarks and links.

    ErzaScarlet77 is there a way i can get a table on web page, have someone edit it without using html/css and have it reflected on the web page? (the person that will be doing the editing have no html/css knowledge)

    Beware! This way lies madness 😃

    dalecosp Beware! This way lies madness 😃

    Yep: you're talking about having a CMS. Get one of those and it will end up assimilating your whole site.

      Write a Reply...