Does anyone here know of a generator that can automatically create tables for you? Basically, I have a site with over 100 pdf files in it, and I want to put them in a table so that they display in a list. Is there a generator that can create the table for me without me having to create each individual link to each pdf?

I don't know if that makes sense or not.

Member Avatar for diafol

Retrieve the list of pdfs from your DB (if stores) or from the folder(s) from a scan/read. There are many functions / techniques for reading directories - glob, SPL functions, even scandir (yuk!).

You can then loop over this list and create a row for each one, adding to a string each time via concatenation.

$str = "<table><thead><tr><th>PDFS</th></thead<tbody>";
foreach($files as $file) $str .= "<tr><td>$file</td></tr>"; 
$str .= "</tbody></table>";
echo $str;

That's a basic technique which you can pad out to create the format and number of fields that you need. I'm sure there are many ready made scripts out there, but this is so simple, I don't see the need. Were you looking for sommething more complicated?

commented: This is what I would go with. I like simple solutions! +12

Were you looking for sommething more complicated?

I was wondering if there was an actual generator already made that can do it. But i can try toying around with that.

diafol's example while not complete is the generator you need. all you are missing is reading from the source, which in your case, i assume the file system.

Here is an example i found with a quick search that could easily be modified to fit your needs.
https://css-tricks.com/snippets/php/display-styled-directory-contents/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.