简体   繁体   中英

Php sql query builder

For a client i am working on a mysql php database with a web interface, and i need to have a section where they can build reports and save them. Does anyone have any suggestions as to how i got about doing this with a table that has 3 or 4 joins on it? And what is the best way to build pdfs with php?

I mean about in terms of displaying to the user and what questions to ask - I was thinking about the office access query wizard and maybe doing something like that. Asking what fields they want to display, what order etc. I was just looking for decent ways to do that and how.

Thank you for the two suggestions for PDF writing, I will look into them.

To generate pdf's in php I use fpdf . It's easy, free, and more functional than some of the alternatives. For more help with the rest of your question I'd really need more information.

There are some pretty decent PDF Libraries available in PHP...TCPDF is pretty easy to use to take HTML and render/output as a PDF.

As far as your question about the database, if the tables are always going to have the same 3 or 4 tables joined, I typically put the table name or alias in front of the field name. If I'm using a multi-select to allow users to select the field, I'd do:

    <option value="mytable.first_name">First Name</option>

I'm obviously making a lot of assumptions here, it'll be harder if there's a variable number of joins because you'll have to manage the tables and the join conditions and apply them when appropriate. If I had to handle a variable number of joins, I'd probably create an array with join conditions; loop through all the fields I have selected above and pull the tables out. Then use the tables in my join array to fetch out the join on directives.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM